[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Example 18 and an Unparsed Character Response
Hiya Kim,
If you run your document through HTTPAPI's XML parser (for example, if
you call http_url_post_xml, as shown in EXAMPLE18) you should get back
the contents of <DeliverContentResult> as one big XML string containing
the whole payload (XML elements and all)
HTTPAPI (or, more correctly, Expat) should've already converted all of
the < > and & entities into their corresponding charaters, so
when you view your 'value' parameter, it should look like a normal XML
document.
Just save that data to disk -- and parse it with http_parse_xml_stmf (or
use another parser like XML-INTO or XML-SAX) and it should parse very
nicely.
Here's an example (an old example from 2008 that's still online) of that
type of logic:
http://www.scottklement.com/httpapi/bankrout.txt
If you're having a hard time understanding, maybe try loading/running
that program. It'll show you each step. First it'll show you the raw
XML (with the < > etc) and then I'll show you the "inner XML" it
extracts from that raw XML. And then it'll parse out the information
from it.
(Assuming the example still works? I haven't looked at it in years.)
On 12/10/2010 3:49 PM, Kim Gibson wrote:
> Hello, everyone!
>
> I'm using Example 18 of HTTPAPI to consume a web service that returns
> prescription data on a client (we are an insurance company).
>
> The web service requires that the data is sent in a soap wrapper, and
> that the main request (variable strVar), is unparsed. Here is what my
> SOAP request looks like:
>
> SOAP =
>
> '<?xml version="1.0" encoding="UTF-8"?>'
>
> +'<soapenv:Envelope '
>
> +%trim(' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"')
>
> +' xmlns:eos="http://QuestWebServices/EOService">'
>
> +'<soapenv:Header />'
>
> +'<soapenv:Body>'
>
> +'<eos:DeliverExamOneContent>'
>
> +'<eos:username>username</eos:username>'
> +'<eos:password>password</eos:password>'
>
> +'<eos:destinationID>RX</eos:destinationID>'
>
> +'<eos:payload><![CDATA['
>
> + %trim(strVar)
>
> +']]></eos:payload>'
>
> +'</eos:DeliverExamOneContent>'
>
> +'</soapenv:Body>'
>
> +'</soapenv:Envelope>';
>
>
> This is working very well, but it's the response (INCOMING) I need to
> ask your advice on.
>
> In the response, the data I want is in an unparsed piece between the
> tags<DeliverContentResult> and</DeliverContentResult>. I was hoping it
> would be returned as nicely formatted XML, but that's not the case. The
> response looks like this--
>
> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><DeliverContentR
> esponse xmlns="http://somewebservice/service">
>
> <DeliverContentResult>
>
> <ReturnValues><TransactionID>7106c824-6cbd-4dec-aacd-94745f3
> a5802</TransactionID><ResponseCode>1</ResponseCode><
> ;ResponseCodeText>Route completed
> successfully</ResponseCodeText><ResponseMessage><TXLife
> xmlns="http://ACORD.org/Standards/Life/2"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://ACORD.org/Standards/Life/2
> TXLife2.19.00.xsd"><TXLifeRequest
> PrimaryObjectID="ID_1"><TransRefGUID>TES099912301-2010-12-0616:
> 24:41</TransRefGUID><TransType tc="1122">General Requirement
> Status/Results
> Transmittal</TransType><TransExeDate>2010-12-10</TransExe
> Date><TransExeTime>15:21:12</TransExeTime><TransMode
> tc="2">Original</TransMode><NoResponseOK tc="1"
> /><OLifE><SourceInfo><SourceInfoName>DataCentral<
> ;/SourceInfoName></SourceInfo><Party
> id="ID_1"><PartyTypeCode
> tc="1">Person</PartyTypeCode><PartyKey>ID_1</PartyKey&
> gt;<GovtID>123456789</GovtID><Person><FirstName>
> KIMBERLEE</FirstName><LastName>TESTINGTHIS</LastName>&
> lt;BirthDate>1944-10-12</BirthDate></Person><Address&g
> t;<AddressTypeCode
> tc="1">Home</AddressTypeCode><Zip>83605</Zip></A
> ddress><Carrier /><Risk><PrescriptionDataStatus
> tc="1">An order has already been sent, but our provider has not
> responded yet. Please consult with your system admin for service
> hours.</PrescriptionDataStatus></Risk></Party></OLi
> fE></TXLifeRequest></TXLife></ResponseMessage></
> ReturnValues>
>
> </DeliverContentResult></DeliverContentResponse></soap:Body></soap:Envel
> ope>
>
> Do you have any suggestions for parsing this unparsed data? There's
> probably some really cool API or something that I'm not aware of?
>
> Thanks so much for your feedback---I've gotten SO much use out of
> HTTPAPI, and since attending Scott's classes at COMMON last Spring in
> Orlando, my boss is now on board with HTTPAPI, too!
>
> Kim Gibson
>
> -----------------------------------------------------------------------
> 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
-----------------------------------------------------------------------