2014-11-13 63 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

这节省了我!谢谢! :-) –