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

查看:42
本文介绍了内容类型 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(发送文本/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天全站免登陆