Why is my Retrieve message failing with "java.lang.NullPointerException" after the upgrade to 19B chat API version?
Environment
Oracle B2C Service - all supported releases
Chat SOAP API - 19B
Resolution
When configuring an integration with the chat API 19B version, one needs to observe the namespacing convention for SOAP requests sent to the server.
This means that the namespace added to the node of the request must be added to its children as well, as in the code sample below:
===============================================
<wsdl:RetrieveMessages>
<wsdl:TransactionRequestData>
<wsdl:ClientRequestTime />
<wsdl:ClientTransactionID>2</wsdl:ClientTransactionID>
<wsdl:SiteName>SiteName</wsdl:SiteName>
</wsdl:TransactionRequestData>
</wsdl:RetrieveMessages>
</env:Body>
==============================================
This will prevent the content of the request (in this case, RetrieveMessages) to be sent as null to the chat server.
When this convention is not observed, the request can fail with one of the two errors below:
==============================
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>Transaction information couldn't be extracted from the request. Make sure the right namespace is used.</faultstring>
<detail>
<ns4:UnexpectedErrorFault xmlns:ns4="urn:faults.chat.ws.rightnow.com/v1" xmlns="urn:messages.common.chat.ws.rightnow.com/v1" xmlns:ns2="urn:messages.uq.chat.ws.rightnow.com/v1" xmlns:ns3="urn:messages.enduser.chat.ws.rightnow.com/v1">
<ns4:exceptionCode>MISSING_MESSAGE_BODY</ns4:exceptionCode>
<ns4:exceptionMessage>Transaction information couldn't be extracted from the request. Make sure the right namespace is used.</ns4:exceptionMessage>
</ns4:UnexpectedErrorFault>
</detail>
</S:Fault>
</S:Body>
</S:Envelope>
or, exceptionally:
=============================
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>java.lang.NullPointerException</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
==============================
More information on how to correctly implement the chat SOAP API with Oracle B2C Service can be found by accessing the online documentation.