Cannot create message: incorrect content-type for SOAP version. Got text/xml; charset=UTF-8, but expected application/soap+xml

Amit picture Amit · Nov 11, 2011 · Viewed 26.1k times · Source

I am trying to use the large merchant services API provided by eBay to upload files onto eBay.

They have provided with a sample.jar file of the same. It seems to be working fine when we execute the .jar file on the command prompt, but when i am trying to integrate its source in my web app its giving me this error. Also i tried to create a web service client using Netbeans and tried to use it, but still it gave me the same error. I also changed the SOAP version from 1.1 to 1.2 but that too doesn't seem to work. The following is the complete stack trace.

Nov 11, 2011 2:59:41 PM com.sun.xml.internal.messaging.saaj.soap.MessageImpl init
SEVERE: SAAJ0533: Cannot create message: incorrect content-type for SOAP version. Got text/xml; charset=UTF-8, but expected application/soap+xml
Nov 11, 2011 2:59:41 PM com.sun.xml.internal.messaging.saaj.soap.MessageImpl init
SEVERE: SAAJ0535: Unable to internalize message
Exception in thread "main" javax.xml.ws.WebServiceException: Couldn't create SOAP message due to exception: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
        at com.sun.xml.internal.ws.util.SOAPConnectionUtil.getSOAPMessage(SOAPConnectionUtil.java:83)
        at com.sun.xml.internal.ws.encoding.soap.client.SOAPXMLDecoder.toSOAPMessage(SOAPXMLDecoder.java:102)
        at com.sun.xml.internal.ws.protocol.soap.client.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:440)
        at com.sun.xml.internal.ws.protocol.soap.client.SOAPMessageDispatcher.doSend(SOAPMessageDispatcher.java:260)
        at com.sun.xml.internal.ws.protocol.soap.client.SOAPMessageDispatcher.send(SOAPMessageDispatcher.java:139)
        at com.sun.xml.internal.ws.encoding.soap.internal.DelegateBase.send(DelegateBase.java:86)
        at com.sun.xml.internal.ws.client.EndpointIFInvocationHandler.implementSEIMethod(EndpointIFInvocationHandler.java:174)
        at com.sun.xml.internal.ws.client.EndpointIFInvocationHandler.invoke(EndpointIFInvocationHandler.java:108)
        at $Proxy28.createUploadJob(Unknown Source)
        at com.SwiftConnectV1.fileprocess.LMS.BulkDataExchangeActions.createUploadJob(BulkDataExchangeActions.java:138)
        at com.SwiftConnectV1.fileprocess.LMS.LMSClientJobs.createUploadJob(LMSClientJobs.java:154)
        at com.SwiftConnectV1.fileprocess.LMS.LMSSample.main(LMSSample.java:74)
Caused by: Couldn't create SOAP message due to exception: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
        at com.sun.xml.internal.ws.util.SOAPUtil.createMessage(SOAPUtil.java:154)
        at com.sun.xml.internal.ws.util.SOAPConnectionUtil.getSOAPMessage(SOAPConnectionUtil.java:78)
        ... 11 more
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
        at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:475)
        at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:278)
        at com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl.<init>(Message1_2Impl.java:61)
        at com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl.createMessage(SOAPMessageFactory1_2Impl.java:62)
        at com.sun.xml.internal.ws.util.SOAPUtil.createMessage(SOAPUtil.java:152)
        ... 12 more
Caused by: com.sun.xml.internal.messaging.saaj.soap.SOAPVersionMismatchException: Cannot create message: incorrect content-type for SOAP version. Got: text/xml; charset=UTF-8 Expected: application/soap+xml
        at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:356)
        ... 16 more

Answer

user159088 picture user159088 · Nov 13, 2011

SAAJ0533: Cannot create message: incorrect content-type for SOAP version. Got text/xml; charset=UTF-8, but expected application/soap+xml

Based on the exception message I say you have something mixed up.

For all SOAP messages sent, the Content-type header should be:

  • text/xml for SOAP v1.1
  • application/soap+xml for SOAP v1.2.

Check these first, then my suggestion would be to try to see what's going on the wire (with Fiddler for ex.) and then compare what's different in your web app as opposed to the sample.jar which works.