這裏的情況: 我開發一個Web服務,它只是獲取的字符串參數和返回DataSet
:從Web服務獲取數據集
[WebMethod]
public DataSet login(string strClientCertificate, string strClientChallengeSigned, string MsgChallenge, string rndNum)
我想消費在客戶端這個Web服務,所以我準備參數和發送它引用我的Web服務:
在客戶端:
DataSet xmlResponse = new DataSet();
MySrvRef.StockServiceSoapClient proxy2 = new StockServiceClient.MySrvRef.StockServiceSoapClient();
xmlResponse = proxy2.login(strCert, strSignedMsg, message, randomNum);
所有我想要的是顯示xmlResponse到c lient,但我有在VS2008這個錯誤:
型「System.ServiceModel.ProtocolException」 未處理的異常出現在mscorlib.dll
其他信息:遠程服務器返回了意外 回覆:(400)錯誤的請求。
我完全困惑。有任何想法嗎?
[EDIT1]
我已經改變了內容長度app.config
文件中的客戶端:
<basicHttpBinding>
<binding name="StockServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
[編輯2] 我甚至改變了我的方法簡單的字符串退貨方式:
[WebMehod]
public string login(string x, string y, string z, string w)
{
return "yes";
}
從客戶端調用它,但得到了相同的協議異常:(。
我在我服務的另一種方法,其定義爲:
[WebMehod]
public byte[] getChallenge()
,我把它叫做沒有客戶端的任何問題。