2014-11-13 65 views
2

我需要調用webservice。我生成了一個代理並調用了該方法。但它一直在失敗。因爲API期望在頭中使用soap/xml,而在Visual Studio中生成的代理客戶端在頭中發送text/xml。將soap/xml中的Soap Request Header從C#中的asmx webservice更改爲soap/xml#

問題:是否可以更改生成的代理客戶端的Content-Type頭的值?

+0

這可能有所幫助:https://social.msdn.microsoft.com/Forums/vstudio/en-US/32e62554-dbe5-483b-830f-df1d2b22a845/client-found-response-content-type-of-but -expected-textxml?forum = wcf – sr28

回答

2

Content Type text/xml; charset=utf-8 was not supported by service

這通常是在客戶機/服務器的綁定,其中在該服務的 消息版本使用SOAP 1.2(其預計 應用/肥皂+ XML)和版本中的失配客戶端使用SOAP 1.1 (它發送文本/ xml)。 WSHttpBinding使用SOAP 1.2,BasicHttpBinding 使用SOAP 1.1。

它通常似乎是一方的wsHttpBinding和另一方面的一個basicHttpBinding。

您可以將客戶端的配置更改爲使用SOAP 1.2的WSHttpBinding,它會影響內容類型標頭。

+0

感謝您的回覆。我能夠改變綁定到wsHttpBinding,它現在發送'application/soap + xml'。但終端正在拒絕該請求,因爲它期望顯式地使用「soap/xml」 – Ody

+0

這節省了我!謝謝! :-) –