Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content Type text/xml; charset=utf-8 was not supported by service

Tags:

wcf

endpoint

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(); 

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. 
like image 352
user1055483 Avatar asked Nov 23 '11 23:11

user1055483


2 Answers

First Google hit says:

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.

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

like image 129
CodeCaster Avatar answered Oct 21 '22 15:10

CodeCaster


Do not forget check the bindings-related code too. So if you wrote:

BasicHttpBinding binding = new BasicHttpBinding(); 

Be sure that all your app.config files contains

<endpoint address="..."           binding="basicHttpBinding" ... 

not the

<endpoint address="..."           binding="wsHttpBinding" ... 

or so.

like image 27
mykola.rykov Avatar answered Oct 21 '22 16:10

mykola.rykov