Content Type application/soap+xml; charset=utf-8 was not supported by service

后端 未结 17 2324
长发绾君心
长发绾君心 2020-12-15 02:54

I am getting the error below while trying to add WCF service to WCFTestClient. I went through a number of solutions on the web but I couldn\'t get it to work.

Can

相关标签:
17条回答
  • 2020-12-15 03:11

    I also came across the same problem. In my case, I was using transfermode = streaming with Mtom. As it turns out, I had named one of my variables (for a structure), "HEADER". This conflicted with the message element [http://tempuri.org/:HEADER] as part of the http service download. Clearly, one must avoid using "reserved" words as parameter name.

    0 讨论(0)
  • 2020-12-15 03:12

    For me, it was very difficult to identify the problem because of a large number of methods and class involved.

    What I did is commented (removed) some methods from the WebService interface and try, and then comment another bunch of methods and try, I kept doing this until I found the method that cause the problem.

    In my case, it was using a complex object which cannot be serialized.

    Good luck!

    0 讨论(0)
  • 2020-12-15 03:14

    I was getting same error while using WebServiceTemplate spring ws [err] org.springframework.ws.client.WebServiceTransportException: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'. [415] [err] at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:665). The WSDL which i was using has soap1.2 protocol and by default the protocol is soap1.1 . When i changed the protocol using below code, it was working

     MessageFactory msgFactory = MessageFactory.newInstance(javax.xml.soap.SOAPConstants.SOAP_1_2_PROTOCOL);
         SaajSoapMessageFactory saajSoapMessageFactory = new SaajSoapMessageFactory(msgFactory);
         saajSoapMessageFactory.setSoapVersion(SoapVersion.SOAP_12);
         getWebServiceTemplate().setMessageFactory(saajSoapMessageFactory);
    
    0 讨论(0)
  • 2020-12-15 03:14

    check the client config file that identified to the web.config on the binding section

    0 讨论(0)
  • 2020-12-15 03:15

    In my case one of the classes didn't have a default constructor - and class without default constructor can't be serialized.

    0 讨论(0)
  • 2020-12-15 03:16

    Here is the example of a web.config that solve the issue for me. Pay attention on the <binding name="TransportSecurity" messageEncoding="Text" textEncoding="utf-8">

    0 讨论(0)
提交回复
热议问题