Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create message: incorrect content-type for SOAP version. Got 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 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
like image 327
Amit Avatar asked Nov 11 '11 09:11

Amit


1 Answers

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

Actually, we got this error because SaajSoapMessageFactory was created "manually" not as a @Bean, so it wasn't taken in charge by the Spring lifecycle and didn't call the afterPropertiesSet method.

So, follow these examples and advices:

  • Example 1
  • Example 2

Hope this help,

like image 51
Romain DEQUIDT Avatar answered Oct 11 '22 23:10

Romain DEQUIDT