[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
HTTPAPI example for GetInfoByZIP
Hello Scott;
First I want to say keep up the good work that you do in providing
solutions to the masses,
I am new to web services and using the HTTPAPI objects. You have wrote
an article on using RPG to consume web services which I've found very
helpful. The thread information included below by Dan was very
important to me for I was interested in using that particular web
service and I had ran across similar problems that Dan had mentioned.
I also copied your example from the thread, complied, and ran the
program but I continue to get the error message "HTTP/1.1 500 Internal
Server Error.". When I go directly to the US ZIP Web Service website
and run the "GetInfoByZip" operation it returns the necessary
information.
What would be your suggestion for my getting the above error?
Thanks Scott.
Lewis
Re: HTTPAPI example for GetInfoByZIP
_________________________________________________________________
* To: HTTPAPI and FTPAPI Projects <[1]ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
* Subject: Re: HTTPAPI example for GetInfoByZIP
* From: Scott Klement <[2]sk@xxxxxxxxxxxxxxxx>
* Date: Thu, 29 Mar 2007 17:23:49 -0500
* In-reply-to:
<[3]1FB078A98D739B4795F3D2FE0DD338F5C1F4A6@xxxxxxxxxxxxxxxxxxxxxxx
xx>
* List-help:
<[4]mailto:ftpapi-request@xxxxxxxxxxxxxxxxxxxxxx?subject=help>
* List-id: HTTPAPI and FTPAPI Projects
<ftpapi.lists.scottklement.com>
* List-post: <[5]mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
* List-subscribe:
<[6]http://www.scottklement.com/mailman/listinfo/ftpapi>,
<[7]mailto:ftpapi-request@xxxxxxxxxxxxxxxxxxxxxx?subject=subscribe
>
* List-unsubscribe:
<[8]http://www.scottklement.com/mailman/listinfo/ftpapi>,
<[9]mailto:ftpapi-request@xxxxxxxxxxxxxxxxxxxxxx?subject=unsubscri
be>
* References:
<[10]1FB078A98D739B4795F3D2FE0DD338F5C1F4A6@xxxxxxxxxxxxxxxxxxxxxx
xxx>
* Reply-to: HTTPAPI and FTPAPI Projects
<[11]ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
* Sender: [12]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
* User-agent: Thunderbird 1.5.0.10 (Windows/20070221)
Hi Dan,
> However, when I try to use the API's to
> [2][13]http://www.webserviceX.NET/GetInfoByZIP, I don't receive any data
> past the GetInfoByZIPResponse tag.
To try it out, I wrote the following program (very quickly). It seems
to work just fine for me... give it a try...
H DFTACTGRP(*NO) BNDDIR('HTTPAPI')
D GETZIPINFO PR ExtPgm('GETZIPINFO')
D Zip 15A const
D GETZIPINFO PI
D Zip 15A const
/copy httpapi_h
/copy ifsio_h
D GetXml PR
D Info likeds(ZipInfo)
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 rc s 10i 0
D SOAP s 1000a varying
D soapfile s 50a varying
D wait s 1A
D ZipInfo ds qualified
D City 40A varying inz
D State 2A inz
D Zip 15A varying inz
D Area_Code 3a varying inz
D TimeZone 3a varying inz
/free
// ------------------------------------------------------------
// Create SOAP Input message:
// ------------------------------------------------------------
SOAP =
'<?xml version="1.0" encoding="UTF-8"?> +
<SOAP-ENV:Envelope +
xmlns:SOAP-ENV="[14]http://schemas.xmlsoap.org/soap/envelope/";> +
<SOAP-ENV:Body> +
<GetInfoByZIP xmlns="[15]http://www.webserviceX.NET";> +
<USZip>' + %trim(Zip) + '</USZip> +
</GetInfoByZIP> +
</SOAP-ENV:Body> +
</SOAP-ENV:Envelope>';
// Convert input message from EBCDIC -> UTF-8
http_setCCSIDs(1208: 0);
// ------------------------------------------------------------
// Send input message to service, and download response
// message to a temporary IFS file:
// ------------------------------------------------------------
soapfile = http_tempfile() + '.soap';
rc = http_url_post( '[16]http://www.webservicex.net/uszip.asmx'
: %addr(SOAP)+2
: %len(SOAP)
: soapfile
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml'
: '[17]http://www.webserviceX.NET/GetInfoByZIP' );
if (rc <> 1);
http_crash();
endif;
// ------------------------------------------------------------
// Parse XML response
// ------------------------------------------------------------
rc = http_parse_xml_stmf( soapfile
: HTTP_XML_CALC
: *null
: %paddr(GetXml)
: %addr(ZipInfo) );
unlink(soapfile);
if (rc < 0);
http_crash();
endif;
// ------------------------------------------------------------
// Display result:
// ------------------------------------------------------------
dsply ('City = ' + ZipInfo.City);
dsply ('State = ' + ZipInfo.State);
dsply ('Zip = ' + ZipInfo.Zip);
dsply ('Area = ' + ZipInfo.Area_Code);
dsply ('TimZn = ' + ZipInfo.TimeZone);
dsply ('Press ENTER to quit') ' ' wait;
*inlr = *on;
return;
/end-free
P GetXml B
D GetXml PI
D Info likeds(ZipInfo)
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 = 'CITY';
Info.City = value;
when name = 'STATE';
Info.State = value;
when name = 'ZIP';
Info.Zip = value;
when name = 'AREA_CODE';
Info.Area_Code = value;
when name = 'TIME_ZONE';
Info.TimeZone = value;
endsl;
/end-free
P E
_________________________________________________________________
Talk to your Yahoo! Friends via Windows Live Messenger. [18]Find Out
How
References
1. mailto:ftpapi@xxxxxxxxxxxxx
2. mailto:sk@xxxxxxxxxxxxx
3. mailto:1FB078A98D739B4795F3D2FE0DD338F5C1F4A6@xxxxxxxxxxxxx
4. mailto:ftpapi-request@xxxxxxxxxxxxxxxxxxxxxx?subject=help
5. mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx
6. http://www.scottklement.com/mailman/listinfo/ftpapi
7. mailto:ftpapi-request@xxxxxxxxxxxxxxxxxxxxxx?subject=subscribe
8. http://www.scottklement.com/mailman/listinfo/ftpapi
9. mailto:ftpapi-request@xxxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe
10. mailto:1FB078A98D739B4795F3D2FE0DD338F5C1F4A6@xxxxxxxxxxxxx
11. mailto:ftpapi@xxxxxxxxxxxxx
12. mailto:ftpapi-bounces@xxxxxxxxxxxxx
13. http://www.webservicex.net/GetInfoByZIP
14. http://schemas.xmlsoap.org/soap/envelope/%22
15. http://www.webservicex.net%22/
16. http://www.webservicex.net/uszip.asmx
17. http://www.webservicex.net/GetInfoByZIP
18. http://www.windowslive.com/explore/messenger?ocid=TXT_TAGLM_WL_messenger_yahoo_082008
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------