我的 WCF 服务有问题。 我有一个控制台应用程序,我需要在不使用 app.config 的情况下使用该服务,因此我必须通过代码设置端点等。 我确实有对 svc 的服务引用,但我无法使用 app.config。 这是我的代码:
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()
时,我收到错误:
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.
请您参考如下方法:
第一个谷歌点击说:
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。