WCF Client Errors Using Java Services

I am currently working on a project where I need to use the Java web service. If I connect to the service using old web services (asmx), it works fine. However, if I try to do the same with the WCF client, I get the following error:

Content Type text / xml; charset = utf-8 of the response message does not match the content type of the binding (application / soap + xml; charset = utf-8). If you use a custom encoder, make sure that the IsContentTypeSupported method is implemented correctly.

My is very simple and looks like this:

//classic web service OldSkoolService.HelloService serviceCall = new esb_wsdlsample.OldSkoolService.HelloService(); Console.WriteLine(serviceCall.SoapVersion); Console.WriteLine(serviceCall.sayHello("something")); HelloServiceClient prototypeClient = new HelloServiceClient(); var serviceChannel = prototypeClient.ChannelFactory; Console.WriteLine(serviceChannel.Endpoint.Binding.MessageVersion); Console.WriteLine(prototypeClient.sayHello("somethinge")); //<-- Error occurs here 

The binding / endpoint configuration file is also simple:

 <bindings> <customBinding> <binding name="Soap12Binding"> <textMessageEncoding messageVersion="Soap12"/> <httpTransport /> </binding> </customBinding> </bindings> <client> <endpoint address="http://10.10.6.51:7001/esb/HelloService" behaviorConfiguration="" binding="customBinding" bindingConfiguration="Soap12Binding" contract="Prototype.ESB.HelloService" name="HelloServicePort" /> </client> 

As a side note, I'm trying to use soap 1.2 because I need to catch exceptions from the service.

+4
source share
2 answers

Based on your error message, this simply means that your server response is SOAP 1.1, while you are expecting SOAP 1.2.

You will need to upgrade to SOAP 1.1 on the client (using BasicHttpBinding, at least do this to check and see if it works that way).

+2
source

Although not required in the SOAP 1.2 specification, it is recommended (i.e. SHOULD ) that SOAP messages use the application / soap content type + xml.

You must change this on the server side. If not, then I think you will have to bother with the textMessageEncoding binding element in the configuration file so that it accepts the content type text / xml.

+1
source

All Articles