使用Web服务时不兼容的类型
我必须使用一个返回字符串作为结果的网络服务,它也获取一些字符串参数,所以我所做的所有事情都是这样的: 1-我已将该服务引用添加到我的项目中。 2-我已经创建了该服务类的实例 3-我在类实例中调用了一个desire函数,
这是我的代码:
MyServiceNS.PscoWSDLPortTypeClient mys= new MyServiceNS.PscoWSDLPortTypeClient();
string res;
res =mys.srvReq("11320000", "21310000", "13901009", "1", "3");
但问题是当我调用mys.srvReq时,我收到如下错误:
内容类型text/xml;响应消息的 charset=ISO-8859-1 与绑定的内容类型不匹配(text/xml; 字符集=utf-8)。如果使用自定义编码器,请确保 IsContentTypeSupported 方法已正确实现。第572章 响应的字节为: ?xml version="1.0" 编码=“ISO-8859-1”?SOAP-ENV:信封 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
I have to use a web service which returns a string as result, it gets some string parameters too, so all things i have done is as this:
1- I have added that service reference to my project.
2- I have created an instance of that service class
3- I have call a desire function within class instance
here is my code:
MyServiceNS.PscoWSDLPortTypeClient mys= new MyServiceNS.PscoWSDLPortTypeClient();
string res;
res =mys.srvReq("11320000", "21310000", "13901009", "1", "3");
But the problem is when i call mys.srvReq i get an error as below:
The content type text/xml; charset=ISO-8859-1 of the response message
does not match the content type of the binding (text/xml;
charset=utf-8). If using a custom encoder, be sure that the
IsContentTypeSupported method is implemented properly. The first 572
bytes of the response were: ?xml version="1.0"
encoding="ISO-8859-1"?SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,问题在于 WFC 不支持 ISO-88859-1 编码。
默认的WFC编码器仅支持utf-8和utf-16编码。
您可以根据 msdn 创建合适的自定义编码器:
http://msdn.microsoft.com/en-us/library/ms751486.aspx
和/或修改这个有用的示例
http://eclectrics.com/software/2009/09/获取当前天气状况/
As I understand it, the problem is with the WFC not supporting the ISO-88859-1 encoding.
The default WFC encoder only supports utf-8 and utf-16 encoding.
You can create a suitable custom encoder as per the msdn:
http://msdn.microsoft.com/en-us/library/ms751486.aspx
And/Or modify this useful example
http://eclectrics.com/software/2009/09/getting-the-current-weather-conditions/