help with SOAP
Fairlight
fairlite at fairlite.com
Tue Nov 14 17:35:37 PST 2006
This public service announcement was brought to you by Enrique Arredondo:
> 3. I get a responce that I have to parse to get the results, I tried
> changing the </ for a CR+</ but I don't know how to use the tr to do all
> that. Or is there a parser like "deurl" to work with some xml:sopa like
> this :
>
> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="h
> ttp://www.w3.org/2001/XMLSchema-instance"
> xmlns:soapenc="http://schemas.xmlsoap.
> org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><env:Body
> env:e
> ncodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><m:createCheckAuthoriza
> tionResponse xmlns:m="http://achex.com"><result
> xmlns:n1="java:com.achex.webserv
> ices" xsi:type="n1:AuthorizationResponse"><clearerID
> xsi:type="xsd:string">12251
> </clearerID><details xsi:nil="true"></details><merchantID
> xsi:type="xsd:string">
> 12251</merchantID><statusCode
> xsi:type="xsd:string">210</statusCode><statusDispl
> ayDescription xsi:nil="true"></statusDisplayDescription><trackingID
> xsi:type="xs
> d:string">12251-11140610230000</trackingID></result></m:createCheckAuthorization
> Response></env:Body></env:Envelope>
Here's basically how you want to do it in layman's terms:
1) Set up a raw I/O based routine to read the file into a dummy variable
no more than 32767 characters at a time (you might try 8192) until it
reaches "</env:Envelope>" within the data stream. This lets you read in an
arbitrarily sized request. If you hit EOF (bytes read is 0, your position
within the file [which you should be tracking with tell() as you bring in
chunks] is equal to what filesize() says the file totals), you know you got
a truncated response.
2) In the midst of all this reading, you want to start looking for your
data. Start working with instr() to find thing like "<env:Body ". Track
where you are within your response with variables (ie., InBody, InCCA,
InResult, etc.) so that you can track whether a piece of data appears where
it should. In each iteration of the loop, conditionally check for data
you're looking for. As you get to the start of the body, set InBody to 1,
etc. As part of the condition for finding trackinID, you should only check
for it if you've got results of 1 for InResult, InCCA, and inBody, for
example.
3) As you parse and find each indicator for chunks of data, chop off the
point to where you found it with an assignment from mid() that takes off
the segment from the start to the correct offset. In this fashion, you'll
be able to keep a rotating buffer in which you can find your data without
exceeding filePro's dummy field length limit. Only read in more data when
what you have no longer has what you're looking for, rinse and repeat until
you have it all and have determined you've hit the end of the proper
request, or have prematurely hit EOF.
It's not going to be pretty, but I've never come up with a better way to do
it, honestly.
mark->
--
Try our new SPF-0 lotion, SunScream[tm]. Get it while it's hot!
More information about the Filepro-list
mailing list