[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Special String in XML file.



Hi Alan,

What you have is an XML document that's the "payload" of a SOAP message. 
  Remember, SOAP can be used to pass any type of data...  you can pass 
normal character strings, obviously, and you can also pass images, 
sound, movies, PDF documents, etc.  ...  and yes, you can pass an XML 
document.

SOAP is intended to represent a call to a routine.

So if you had this:

        CALL MYROUTINE( parm1, parm2 )

Then the soap message might look like this:

<Envelope>
   <Body>
      <MyRoutineInput>
        <parm1>..contents of parm1...</parm1>
        <parm2>..contents of parm2...</parm2>
     </MyRoutineInput>
   <Body>
</Envelope>

But if you were doing this in Java, PHP, C#, or any other tool that 
handles the SOAP processing for you, you'd never see this SOAP message. 
  All you'd know is that you called MYROUTINE and passed the two parameters.

Well, what would happen if you did this?

    parm1 = '<myXml>blah</myXml>';
    CALL MYROUTINE( parm1, parm2 )

Remember, most web service consumers don't even know the SOAP message 
exists... but they want to pass XML data as a parameter to a routine... 
  So what happens in the SOAP message that occurs under the covers?

<Envelope>
   <Body>
      <MyRoutineInput>
        <parm1>&lt;xmXML&gt;blah&lt;/myXml&gt;</parm1>
        <parm2>..contents of parm2...</parm2>
     </MyRoutineInput>
   <Body>
</Envelope>

So this is a fairly common thing...  the XML is being passed as a 
parameter.

The caller certainly expects the XML to be passed as a string to the 
routine it calls. It does NOT expect the SOAP parser (which is under the 
covers, and invisible) to parse the contents of myXML -- that makes no 
sense!

I guess you could say that the problem with HTTPAPI as a web service 
tool is that it's NOT A WEB SERVICE TOOL.  It's an HTTP tool.  It passes 
data over the network, but it does nothing to take care of the SOAP 
message.  Personally, I've not found it hard to handle soap messages by 
hand -- and the way HTTPAPI handles it is MUCH more versatile than other 
tools (like IWS client, for example.)

So anyway, to answer your question:   You're asking the wrong question. 
  You don't want Expat to treat the &lt; and &gt; (etc) as < and >.  You 
don't WANT it to parse that as part of the SOAP message.

But, you DO need to parse the XML twice!  You need to parse the SOAP 
message to get the contents of the parameters (i.e. parm1 in my example, 
or 'operationResult' in your example).  The data in the 
'operationResult' will be the XML string that was passed to you as a 
parameter, and all of the &lt;, &gt;, etc should be decoded for you (but 
unparsed) when you receive the contents of operationResult

NOW you've got the contents of your parameter, so you you can parse the 
XML that's inside of it  (as a separate step).  To do that, you can use 
RPG's XML-INTO or XML-SAX opcodes, or you can use HTTPAPI's 
http_parse_xml_stmf or http_parse_xml_string, or you can call Expat 
directly... whatever you prefer.

An example of this type of processing with HTTPAPI is here:
http://www.scottklement.com/httpapi/bankrout.txt



On 4/28/2011 6:48 PM, Alan Campin wrote:
>
>     I have a XML document that I am receiving that a package that is
>     inside a soap envelope.
>
>
>     Using the EXAMPLE17 that is included in the HTTP downloads I can see
>     how to process and extract the inside package but it has strings
>     instead of special characters.
>
>
>     It has
>
>
>     &lt; =<
>
>     &gt; =>
>
>     &quot; = "
>
>
>     Is there a way to tell Expat using the HTTP api's to recognize these
>     strings as the symbols or does it just recognize them as such (PC
>     editors don't seem to) or am I going to have to read the file through
>     and write back with symbols?
>
>
>     Thanks for the help.
>
>
>     Operation Result is the inside package.
>
>
>     <?xml version='1.0' encoding='UTF-8'?>
>
>     <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/";>
>
>                     <S:Body>
>
>                                     <ns2:ServiceResponse
>     xmlns:ns2="http://stem.startrak.com/gw/";>
>
>                                                     <status>0</status>
>
>
>     <sessionId>-5701ce8f:12f9516f837:-396d</sessionId>
>
>
>     <operationResult>&lt;?xml version=&quot;1.0&quot;
>
>
>     encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
>
>
>     &lt;ns2:StMessage
>
>
>     xmlns:ns2=&quot;http://ramp.startrak.com/RAMP.1.0.0/&quot;&gt;
>
>
>     &lt;status&gt;0&lt;/status&gt;
>
>
>     &lt;messageTypes&gt;REEFER_STATUS&lt;/messageTypes&gt;
>
>
>     &lt;messageCount&gt;1&lt;/messageCount&gt;
>
>
>     &lt;queueStatus&gt;MORE_DATA&lt;/queueStatus&gt;
>
>
>     &lt;ReeferStatusMessage&gt;
>
>
>     &lt;asset&gt;
>
>
>     &lt;assetName&gt;ENGZ30280&lt;/assetName&gt;
>
>
>     &lt;assetState&gt;1&lt;/assetState&gt;
>
>
>     &lt;config&gt;
>
>
>     &lt;microConfig&gt;
>
>
>     &lt;microManufacturer&gt;1&lt;/microManufacturer&gt;
>
>
>     &lt;microModel&gt;3&lt;/microModel&gt;
>
>
>     &lt;microType&gt;1&lt;/microType&gt;
>
>
>     &lt;compartmentCount&gt;1&lt;/compartmentCount&gt;
>
>
>     &lt;/microConfig&gt;
>
>
>     &lt;rtConfig&gt;
>
>
>     &lt;unitSerialNumber&gt;GCTH001730&lt;/unitSerialNumber&gt;
>
>
>     &lt;unitFirmwareRelease&gt;W0096&lt;/unitFirmwareRelease&gt;
>
>
>     &lt;unitFirmwareVersion&gt;3.52&lt;/unitFirmwareVersion&gt;
>
>
>     &lt;/rtConfig&gt;
>
>
>     &lt;/config&gt;
>
>
>     &lt;/asset&gt;
>
>
>     &lt;reeferStatus&gt;
>
>
>     &lt;alerts&gt;
>
>
>     &lt;batteryAlert&gt;0&lt;/batteryAlert&gt;
>
>
>     &lt;fuelAlert&gt;0&lt;/fuelAlert&gt;
>
>
>     &lt;pmAlert&gt;1&lt;/pmAlert&gt;
>
>
>     &lt;temp1Alert&gt;0&lt;/temp1Alert&gt;
>
>
>     &lt;temp2Alert&gt;0&lt;/temp2Alert&gt;
>
>
>     &lt;temp3Alert&gt;0&lt;/temp3Alert&gt;
>
>
>     &lt;/alerts&gt;
>
>
>     &lt;ambientTemp&gt;89.6&lt;/ambientTemp&gt;
>
>
>     &lt;batteryVoltage&gt;12.5&lt;/batteryVoltage&gt;
>
>
>     &lt;compartmentStatus&gt;
>
>
>     &lt;number&gt;1&lt;/number&gt;
>
>
>     &lt;setpointTemp&gt;-10.0&lt;/setpointTemp&gt;
>
>
>     &lt;/compartmentStatus&gt;
>
>
>     &lt;door1Status&gt;-1&lt;/door1Status&gt;
>
>
>     &lt;door2Status&gt;0&lt;/door2Status&gt;
>
>
>     &lt;engineHours&gt;13505&lt;/engineHours&gt;
>
>
>     &lt;event&gt;
>
>
>     &lt;eventCode&gt;35044&lt;/eventCode&gt;
>
>
>     &lt;eventType&gt;0&lt;/eventType&gt;
>
>
>     &lt;/event&gt;
>
>
>     &lt;fuel&gt;74.0&lt;/fuel&gt;
>
>
>     &lt;gps&gt;
>
>
>     &lt;city&gt;WARREN&lt;/city&gt;
>
>
>     &lt;geofence&gt;
>
>
>     &lt;geofenceId&gt;0&lt;/geofenceId&gt;
>
>
>     &lt;/geofence&gt;
>
>
>     &lt;latitude&gt;41.17205858&lt;/latitude&gt;
>
>
>     &lt;longitude&gt;-80.80940008&lt;/longitude&gt;
>
>
>     &lt;state&gt;OH&lt;/state&gt;
>
>
>     &lt;/gps&gt;
>
>
>     &lt;hookStatus&gt;-1&lt;/hookStatus&gt;
>
>
>     &lt;intelliset&gt;
>
>
>     &lt;intellisetCode&gt;-1&lt;/intellisetCode&gt;
>
>
>     &lt;intellisetState&gt;1&lt;/intellisetState&gt;
>
>
>     &lt;/intelliset&gt;
>
>
>     &lt;messageStamp&gt;2011-04-27T13:54:59.000Z&lt;/messageStamp&gt;
>
>
>     &lt;reeferAlarmStatus&gt;0&lt;/reeferAlarmStatus&gt;
>
>
>     &lt;reeferMoveStatus&gt;1&lt;/reeferMoveStatus&gt;
>
>
>     &lt;serviceState&gt;3&lt;/serviceState&gt;
>
>
>     &lt;standbyHours&gt;0&lt;/standbyHours&gt;
>
>
>     &lt;switchOnHours&gt;23475&lt;/switchOnHours&gt;
>
>
>     &lt;reeferPower&gt;0&lt;/reeferPower&gt;
>
>
>     &lt;/reeferStatus&gt;
>
>
>     &lt;systemStatus&gt;
>
>
>     &lt;correlationId&gt;1001&lt;/correlationId&gt;
>
>
>     &lt;isRedelivered&gt;false&lt;/isRedelivered&gt;
>
>
>     &lt;numberOfRetries&gt;1&lt;/numberOfRetries&gt;
>
>
>     &lt;queuedStamp&gt;2011-04-27T14:00:46.292Z&lt;/queuedStamp&gt;
>
>
>     &lt;/systemStatus&gt;
>
>
>     &lt;/ReeferStatusMessage&gt;
>
>
>     &lt;/ns2:StMessage&gt;</operationResult>
>
>                                     </ns2:ServiceResponse>
>
>                     </S:Body>
>
>     </S:Envelope>
>
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------