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

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

They provided the sample.jar file of the same. It seems to work fine when we run the .jar file on the command line, but when I try to integrate its source into my web application, it gives me this error. I also tried to create a web service client using Netbeans and tried to use it, but it still threw the same error. I also changed the SOAP version from 1.1 to 1.2, but this does not work either. Below is a 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 
+8
source share
2 answers

To work, it seems that my JDK was corrupted with all the external jar files that I added to make it work. Updated to Java 7, and now it works fine.

-5
source

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

Based on the exception message, I say that you have something messed 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.

First check this out, then my suggestion will try to see what happens on the explorer (with Fiddler for example) and then compare what is different from your web application, unlike sample.jar , which works.

+26
source

All Articles