[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need simple request help.
Hi Mike,
> This service appears to have SOAP interface as well a couple of other
> formats. http://geocoder.us/help/
[SNIP]
> Would it be possible to impose on you to whip up the SOAP version so those
> of us learning can see the same thing from a slightly different perspective?
Sure. In some ways the SOAP version is simpler because you don't have
to write anything to decode the result -- the XML parser does it for
you. On the other hand, there's more things that you can do wrong,
since HTTPAPI doesn't have a SOAP encoder, but it does have a URL
encoder. That means that the programmer is fully responsible for
creating the SOAP message, and has to get every detail right.
I haven't benchmarked them, but I'd suspect the CSV one to be faster as
well, since it doesn't require the extra complexity of the XML parser.
But, the different may be negligible.
Here's a sample SOAP version:
h dftactgrp(*no) bnddir('HTTPAPI')
/copy httpapi_h
D Incoming PR
D res likeds(Result)
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 32767A varying const
D attrs * dim(32767)
D const options(*varsize)
D Result ds qualified
D Lat 13p 8
D Lon 13p 8
D COORDSIZE C %len(Result.Lat)
D COORDDEC C %decpos(Result.Lat)
D location s 1000A
D soap s 2000a varying
D rc s 10i 0
/free
location = '1600 W. Pennsylvania Ave NW, '
+ 'Washington,DC';
soap = '+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>+
<SOAP-ENV:Envelope +
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" +
xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
<SOAP-ENV:Body>+
<geocode xmlns="http://rpc.geocoder.us/Geo/Coder/US/" +
SOAP-ENV:encodingStyle=+
"http://schemas.xmlsoap.org/soap/encoding/"> +
<location xsi:type="xsd:string"><![CDATA[' +
%trim(Location) +
']]></location>+
</geocode>+
</SOAP-ENV:Body>+
</SOAP-ENV:Envelope>';
http_debug(*on);
http_setCCSIDs( 1208: 0 );
rc = http_url_post_xml( 'http://rpc.geocoder.us/service/soap'
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: %addr(Result)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml'
: 'http://rpc.geocoder.us/Geo/Coder/US#geocode');
if (rc <> 1);
http_crash();
else;
http_comp('Lat=' + %char(Result.lat) + ', ' +
'Lon=' + %char(Result.lon) );
endif;
*inlr = *on;
/end-free
P Incoming B
D Incoming PI
D res likeds(Result)
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 32767A varying const
D attrs * dim(32767)
D const options(*varsize)
/free
select;
when name = 'lat';
Res.Lat = %dec( value: COORDSIZE: COORDDEC);
when name = 'long';
Res.Lon = %dec( value: COORDSIZE: COORDDEC);
endsl;
/end-free
P E
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------