内容类型text/xml;服务不支持charset = utf-8 [英] Content Type text/xml; charset=utf-8 was not supported by service

查看:1545
本文介绍了内容类型text/xml;服务不支持charset = utf-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对WCF服务有问题. 我有一个控制台应用程序,不需要使用app.config就可以使用该服务,因此必须通过代码设置端点等. 我确实有对svc的服务引用,但无法使用app.config. 这是我的代码:

I have a problem with a WCF service. I have a console application and I need to consume the service without using app.config, so I had to set the endpoint, etc. by code. I do have a service reference to the svc, but I can't use the app.config. Here's my code:

BasicHttpBinding binding = new BasicHttpBinding();

EndpointAddress address = new EndpointAddress("http://localhost:8731/WcfServicio/MiServicio");

MiServicioClient svc = new MiServicioClient(binding, address);
object ob = svc.PaisesObtener();

当我执行svc.PaisesObtener()的最后一行时,出现错误:

At the last line when I do svc.PaisesObtener() I get the error:

Content Type text/xml; charset=utf-8 was not supported by service
http://localhost:8731/WcfServicio/MiServicio.  The client and service bindings may be mismatched.

推荐答案

第一个Google匹配是:

First Google hit says:

这通常是客户端/服务器绑定中的不匹配,其中服务中的消息版本使用SOAP 1.2(需要application/soap + xml),而客户端中的版本使用SOAP 1.1(发送text/xml) . WSHttpBinding使用SOAP 1.2,BasicHttpBinding使用SOAP 1.1.

this is usually a mismatch in the client/server bindings, where the message version in the service uses SOAP 1.2 (which expects application/soap+xml) and the version in the client uses SOAP 1.1 (which sends text/xml). WSHttpBinding uses SOAP 1.2, BasicHttpBinding uses SOAP 1.1.

通常一侧似乎是wsHttpBinding,而另一侧是basicHttpBinding.

It usually seems to be a wsHttpBinding on one side and a basicHttpBinding on the other.

这篇关于内容类型text/xml;服务不支持charset = utf-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆