Question

We have this bit of code creating an XML Message within a SAAJ SOAP message:

OdysseyMessageXML.addTextNode("<Message
MessageType='FindCaseByCaseNumber' NodeID='1' ReferenceNumber='1'
UserID='1'
Source='APIMessage'><CaseNumber>T-4-CV-2011-004617</CaseNumber></Message>"
);

When the message is complete it looks like this:

<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tyl="http://www.tylertech.com/"><SOAP-ENV:Header/>
<SOAP-ENV:Body><tyl:OdysseyMsgExecution><tyl:OdysseyMessageXML>&lt;Message
 MessageType='FindCaseByCaseNumber' NodeID='1' ReferenceNumber='1'
UserID='1'
Source='APIMessage'&gt;&lt;CaseNumber&gt;T-4-CV-2011-004617&lt;/CaseNumber&gt;
&lt;/Message&gt;</tyl:OdysseyMessageXML>
<tyl:siteKey>NMODYSSEYMETRO</tyl:siteKey>
</tyl:OdysseyMsgExecution></SOAP-ENV:Body></SOAP-ENV:Envelope>

notice that the ' marks around FindCaseByCaseNumber and NodeID are NOT escaped. What do I need to do to get the results like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:tyl="http://www.tylertech.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <tyl:OdysseyMsgExecution>
         <tyl:odysseyMessageXML>&lt;Message
 MessageType=&quot;FindCaseByCaseNumber&quot; NodeID=&quot;1&quot; 
ReferenceNumber=&quot;1&quot; UserID=&quot;1&quot; Source=&quot;
APIMessage&quot;&gt;
&lt;CaseNumber&gt;T-4-CV-2011-004617&lt;/CaseNumber&gt;
  &lt;/Message&gt;</tyl:odysseyMessageXML>
         <tyl:siteKey> NMODYSSEYMETRO </tyl:siteKey>
      </tyl:OdysseyMsgExecution>
   </soapenv:Body>
</soapenv:Envelope>

with the " around FindCaseByCaseNumber

can anyone tell me what we are doing incorrectly? We have tried in the addTextNode portion of the code ''' and """ but have been unsuccessful in getting the quotes escaped.

thanks! Leslie

edit:

In this section of the code where we are creating the message:

OdysseyMessageXML.addTextNode("<Message
MessageType='FindCaseByCaseNumber' NodeID='1' ReferenceNumber='1'
UserID='1'
Source='APIMessage'><CaseNumber>T-4-CV-2011-004617</CaseNumber></Message>"
); 

we need it to be (see double quotes around each value):

OdysseyMessageXML.addTextNode("<Message
MessageType="FindCaseByCaseNumber" NodeID="1" ReferenceNumber="1"
UserID="1"
Source="APIMessage"><CaseNumber>T-4-CV-2011-004617</CaseNumber></Message>"
); 

unfortunately this is NOT valid java code. By placing another " at FindCaseByCaseNumber it ends the string. We have tried putting 2 and 3 double quotes in order to get a single double quote escaped in our final message.

Update: It appears that the API that is accepting our request is case sensitive and we had a capital O instead of a lower case o which was ultimately the problem, not the character escaping after all!

Was it helpful?

Solution

You can escape the quotes in your string with a backslash:

OdysseyMessageXML.addTextNode("<Message
MessageType=\"FindCaseByCaseNumber\" NodeID=\"1\" ReferenceNumber=\"1\"
UserID=\"1\"
Source=\"APIMessage\"><CaseNumber>T-4-CV-2011-004617</CaseNumber></Message>"
); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top