Sunday, January 5, 2014

SOAP Version Mismatch between Consumer and Publisher


While consuming the SOAP service I got the below error . This took me couple of minutes to figure out so thought of sharing may be this can save some minutes .


Error 1:

 <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body>
<pnd:ConvertPNG2PDFResponse xmlns:pnd="http://mycompany.com/middleware/utility/conversion/pnd2pdf"><ser:ResponseHeader xmlns:ser="http://mycompany.com/middleware/schemas/servicemetadata_v1"><ser:StatusCode>1</ser:StatusCode><ser:Status>ERROR</ser:Status><ser:MessageCode>OSB-UNREG-ERR</ser:MessageCode><ser:Message>
This error is not registered in the system. Please Contact system administrator.BEA-382032-The message must be an instance of: {http://www.w3.org/2003/05/soap-envelope}Envelope
</ser:Message>
</ser:ResponseHeader>
</pnd:ConvertPNG2PDFResponse>
</soap:Body></soap:Envelope>

Error 2:

Response SOAP Message = <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:VersionMismatch</faultcode><faultstring>BEA-382032: The message must be an instance of: {http://schemas.xmlsoap.org/soap/envelope/}Envelope</faultstring><detail><con:fault xmlns:con="http://www.bea.com/wli/sb/context"><con:errorCode>BEA-382032</con:errorCode><con:reason>
The message must be an instance of: {http://schemas.xmlsoap.org/soap/envelope/}Envelope</con:reason><con:details><err:InvalidEnvelope xmlns:err="http://www.bea.com/wli/sb/errors"><err:localpart>Envelope</err:localpart><err:namespace>http://www.w3.org/2003/05/soap-envelope</err:namespace></err:InvalidEnvelope></con:details><con:location><con:path>request-pipeline</con:path></con:location></con:fault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

Solution : while creating the MessageFactory object please use the correct arguments based on the published service if this is SOAP 1.1 or 1.2

Please refer the below for more information
Open Declaration

A factory for creating SOAPMessage objects.
A SAAJ client can create a MessageFactory object using the method newInstance, as shown in the following lines of code.
       MessageFactory mf = MessageFactory.newInstance();
       MessageFactory mf12 = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
 
All MessageFactory objects, regardless of how they are created, will produce SOAPMessage objects that have the following elements by default:
  • A SOAPPart object
  • A SOAPEnvelope object
  • A SOAPBody object
  • A SOAPHeader object
In some cases, specialized MessageFactory objects may be obtained that produce messages prepopulated with additional entries in the SOAPHeader object and the SOAPBody object. The content of a new SOAPMessage object depends on which of the two MessageFactory methods is used to create it.
  • createMessage()
    This is the method clients would normally use to create a request message.
  • createMessage(MimeHeaders, java.io.InputStream) -- message has content from the InputStream object and headers from the MimeHeaders object
    This method can be used internally by a service implementation to create a message that is a response to a request.  

1 comment:

  1. If you encountered an issue while consuming a SOAP service, please provide more details about the specific error or problem you encountered. The Perantu Panthan This information will help me assist you in resolving the issue effectively.

    ReplyDelete