0

開発 Web サーバー (下の画面) から Web サービスをテストするとき、INVOKE ボタンをクリックすると、新しいウィンドウが開き、OPEN または SAVE のプロンプトが表示され、ファイルタイプに関連付けられたアプリケーションがウィンドウでファイルを開きます。

webmethod の localhost テスト

ColdFusion(CF) 開発者が webmethod を呼び出したときにこれが機能することを期待して、.Net webclient に数行のコードを追加して同じ webmethod を呼び出すことにより、CF テストをシミュレートしようとしました。

protected void DownloadButton3_Click(object sender, EventArgs e)
    {
        string r = txtRecordNumber.Text;
        DownloadCF(r);
    }
    private void DownloadCF(string recNumber)
    {
        string fakeURLparm = txtFakeURLParm.Text;
        brokerService.Timeout = 9999999;
        brokerService.Credentials = System.Net.CredentialCache.DefaultCredentials;
        brokerService.DownloadFileCF(fakeURLparm, recNumber);
    }

この ASP.Net ページを呼び出し元として使用すると、非常に奇妙なエラーが発生します (以下を参照)。DownloadCF メソッドの後に SoapHttpClientProtocol.Invoke メソッドとエラーが続く StackTrace に注意してください。一方のアプローチが失敗し、もう一方の Invoke が適切に機能する理由がわかりません。

「/sdkTrimFileServiceASMXclient」アプリケーションでサーバー エラーが発生しました。

Data at the root level is invalid. Line 1, position 1. 
Description: An unhandled exception occurred during the execution of the current web request.       Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

Source Error: 


Line 231:        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://cbmiweb.com/sdkTrimFileServiceASMX/DownloadFileCF", RequestNamespace="http://cbmiweb.com/sdkTrimFileServiceASMX/", ResponseNamespace="http://cbmiweb.com/sdkTrimFileServiceASMX/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 232:        public string DownloadFileCF(string trimURL, string TrimRecordNumber) {
Line 233:            object[] results = this.Invoke("DownloadFileCF", new object[] {
Line 234:                        trimURL,
Line 235:                        TrimRecordNumber});
Source File: C:\ProjectsVS2010\sdkTrimFileServiceASMX\FileServiceProxy\Web References\ASMXproxy\Reference.cs    Line: 233 
Stack Trace: 
[XmlException: Data at the root level is invalid. Line 1, position 1.]
   System.Xml.XmlTextReaderImpl.Throw(Exception e) +76
   System.Xml.XmlTextReaderImpl.Throw(String res, String arg) +126
   System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() +3975494
   System.Xml.XmlTextReaderImpl.ParseDocumentContent() +187
   System.Xml.XmlTextReaderImpl.Read() +151
   System.Xml.XmlTextReader.Read() +15
   System.Xml.XmlReader.MoveToContent() +64
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +502
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204

[InvalidOperationException: Response is not well-formed XML.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +282
   FileServiceProxy.ASMXproxy.FileService.DownloadFileCF(String trimURL, String TrimRecordNumber) in C:\ProjectsVS2010\sdkTrimFileServiceASMX\FileServiceProxy\Web References\ASMXproxy\Reference.cs:233
   WebClient.launcher.DownloadCF(String recNumber) in C:\ProjectsVS2010\sdkTrimFileServiceASMX\WebClient\launcher.aspx.cs:368
   WebClient.launcher.DownloadButton3_Click(Object sender, EventArgs e) in C:\ProjectsVS2010\sdkTrimFileServiceASMX\WebClient\launcher.aspx.cs:360
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3623; ASP.NET Version:2.0.50727.3618 

-----編集/更新: Fiddler2 からのセッション情報 これを開始するためのセッションが 1 つあります。結果コードは 200 です。応答の WebView タブは、私の webclient ページとまったく同じように見えます。ボタンをクリックすると、ここに貼り付けられた Fiddler2 の新しいセッションが 1 つだけ取得されます。

#   Result  Protocol    Host    URL Body    Caching Content-Type    Process Comments    Custom  
8   500 HTTP    mdwdata /sdkTrimFileServiceASMXclient/launcher.aspx 8,167   private     text/html; charset=utf-8    iexplore:4400           

以下は、そのセッションの Raw リクエストの貼り付けです (見苦しいですが、他にどのように説明すればよいでしょうか?): POST http://mdwdata/sdkTrimFileServiceASMXclient/launcher.aspx HTTP/1.1 Accept: image/gif, image/jpeg, image/ pjpeg、image/pjpeg、application/x-ms-application、application/x-ms-xbap、application/vnd.ms-xpsdocument、application/xaml+xml、application/vnd.ms-excel、application/vnd.ms- powerpoint, application/msword, /リファラー : http://mdwdata/sdkTrimFileServiceASMXclient/launcher.aspx Accept-Language: en-us User-Agent: Mozilla/4.0 (互換性あり; MSIE 7.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; . NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.3) コンテンツ タイプ: マルチパート/フォーム データ; 境界= ---------------------------7db1e23703ae Accept-Encoding: gzip、deflate Host: mdwdata Content-Length: 2844 Connection: Keep-Aliveプラグマ: no-cache

-----------------------------7db1e23703ae
Content-Disposition: form-data; name="__EVENTTARGET"


-----------------------------7db1e23703ae
Content-Disposition: form-data; name="__EVENTARGUMENT"


-----------------------------7db1e23703ae
Content-Disposition: form-data; name="__LASTFOCUS"


-----------------------------7db1e23703ae
Content-Disposition: form-data; name="__VIEWSTATE"

/wEPDwULLTEzNzAzNDU3MjgPZBYCAgMPFgIeB2VuY3R5cGUFE211bHRpcGFydC9mb3JtLWRhdGEWAgIBDw8WAh4EVGV4dAUTV2ViQ2xpZW50IC0gMS4zLjguMGRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQpMb2dMaXN0Qm94GPOeMic5o+L85SmULO5z3yzNQcQ=
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="__PREVIOUSPAGE"

yXPNVTg4Wvj3GjytyxWv8KoyO3MLbzw51kYChzcsuxZx7IxumYcxmkwqQIAVLmSjaEaH0sfkMpmaEFPuQoLRia8YUKhPVhh5NxqSDzyGa4Y-LGkkCe5CJRK1Rm2TUnL7Mw3w4Q2
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="__EVENTVALIDATION"

/wEWEALh4p2SAQK6+/bUAgK5gaaMBQKskZf8CwLJ0JnWAwL99O3eCQKdnvCuBgLGrJLIBAKNmrGmBQKmiPS0AQKpssxKAsSb6t8KAt+EiPUEApi43CQCoqfWowgC/8zR1Ay0LlmsrFijDr0zW8kPfHiRkTNgYw==
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtURL"

http://MDWDATA/sdkTrimFileServiceASMX/
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtTrimDBID"

60
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtWorkGroupServerName"

GROUPER
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtWorkGroupServerPort"

1137
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtFakeURLParm"

60~GROUPER~1137
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtTrimRecordType"

Document
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtOptionalMetaData"

udf:Agency=MACTE~udf:Grant Number=0102030405
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="FileUpload1"; filename=""
Content-Type: application/octet-stream


-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtRecordNumber"

5
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="DownloadButton3"

DownloadFileCF webmethod to HTTPContext.Current
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtCFSearchString"

sm_fulltext=google&sm_fulltext=docs&bool=and&sm_udf5=macte&sm_udf14=f&sortd1=rs_dateregistered&count&rows=50
-----------------------------7db1e23703ae
Content-Disposition: form-data; name="txtMultiLine"

User Name: CBMIWEB\johna
 Token: 988
 Authenticated: Kerberos
 System: False
 Guest: False
 Anonymous: False

-----------------------------7db1e23703ae--

Fiddler2 からのそのセッションからの対応する Response は、XML 例外 ( Data at the root level is invalid. Line 1, position 1. )からのスタック トレースが続く一連のスタイリングを含む単純な HTML ページです。上に投稿したのでここでは繰り返さない。

何が間違っている可能性があるかについての理論がありますが、更新された投稿をこれ以上作成することを本当にためらっています (新しい質問を開いて、これを背景情報として参照することを考えています)。提案?

4

0 に答える 0