[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help request on HTTPAPI
Hello,
EXAMPLE18 demonstrates the currency converter. No need to modify EXAMPLE19.
I've noticed that a lot of the EXAMPLExx programs don't work. They
worked when they were first added to HTTPAPI, but the web servers have
changed over the years and discontinued the functionality. I'm going to
go over all of the EXAMPLE programs for the next release, and replace
the examples that don't work with different ones that do.
Tanampasidis George wrote:
> I wonder if someone can help me with the HTTPAPI. I
> downloaded the httpapi a few days ago and I try to run one of the
> examples listed in the qrpglesrc source file (example 19).
> Unfortunately, the Translate web service does not work (you can verify
> it from the [1]www.webservicex.net site). Therefore, I tried to modify
> the example19 program, in order to consume another webservice from the
> same web server. The webservice I try to consume is the
> CurrencyConvertor.
>
>
> When I call the program I get the following error: HTTP/1.1 400 Bad
> Request
>
>
> The prgle program that tries to consume the web service is listed
> below:
>
>
>
> *
>
> H DFTACTGRP(*NO) BNDDIR('HTTPAPI')
>
>
> D GT_EXMPL1 PR ExtPgm('GT_EXMPL1')
>
> D Curr1 3A const
>
> D Curr2 3A const
>
> D GT_EXMPL1 PI
>
> D Curr1 3A const
>
> D Curr2 3A const
>
>
> /copy httpapi_h
>
>
> D Incoming PR
>
> D String 32767A varying
>
> D depth 10I 0 value
>
> D name 1024A varying const
>
> D path 24576A varying const
>
> D value 65535A varying const
>
> D attrs * dim(32767)
>
> D const options(*varsize)
>
>
> D SOAP s 2000A varying
>
> D rc s 10I 0
>
> D String s 1000A varying
>
> D Lang s 32A
>
> D LangMode s 41A varying
>
> d peBasic s 1N
>
> d peRealm s 124A
>
> d proxyName s 100A inz('PROXYSRV')
>
> d mTimeOut s 3S 0 inz(10)
>
>
>
> /free
>
> *inlr = *on;
>
>
> if %parms < 2;
>
> http_comp('This program requires 2 parms,' +
>
> ' Curr1 & Curr2 ');
>
> *inlr = *on;
>
> return;
>
> endif;
>
>
> http_debug(*ON);
>
> rc = http_setproxy( %trim(proxyName) : 8080 );
>
> // rc = http_proxy_getauth( peBasic : peRealm );
>
> rc = http_proxy_setauth( HTTP_AUTH_NONE :
>
> `username' :
>
> 'password' );
>
> if (rc <> 0);
>
> http_crash();
>
> return;
>
> endif;
>
>
>
> SOAP =
>
> '<?xml version="1.0" encoding="UTF-8"?>'
>
> +'<soap:Envelope'
>
> +' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
>
> +' xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
>
> +' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" '
>
> +'<soap:Body>'
>
> +' <ConversionRate xmlns="http://www.webserviceX.NET/"> '
>
> +' <FromCurrency>' + Curr1 +'</FromCurrency>'
>
> +' <ToCurrency>' + Curr2 +'</ToCurrency>'
>
> +' </ConversionRate>'
>
> +'</soap:Body>'
>
> +'</soap:Envelope>';
>
>
> rc = HTTP_setCCSIDs(1208: 0); // CCSID 1208 = UTF-8
>
>
> rc = http_url_post_xml(
>
> 'http://www.webservicex.net/CurrencyConvertor.asmx'
>
> : %addr(SOAP) + 2
>
> : %len(SOAP)
>
> : *NULL
>
> : %paddr(Incoming)
>
> : %addr(String)
>
> : mTimeOut
>
> : HTTP_USERAGENT
>
> : 'text/xml; charset=utf-8'
>
> :
> 'http://www.webserviceX.NET/ConversionRate');
>
> if (rc <> 1);
>
> http_crash();
>
> else;
>
> http_comp(String);
>
> endif;
>
>
>
> /end-free
>
> C return
>
>
> P Incoming B
>
> D Incoming PI
>
> D String 32767A varying
>
> D depth 10I 0 value
>
> D name 1024A varying const
>
> D path 24576A varying const
>
> D value 65535A varying const
>
> D attrs * dim(32767)
>
> D const options(*varsize)
>
>
> /free
>
> if (name = 'ConversionRateResult');
>
> String = value;
>
> endif;
>
> /end-free
>
> P E
>
>
>
> I have switched on the debugger and the messages which are printed out
> in the httpapi_debug stream file are the following:
>
>
> HTTPAPI Ver 1.23 released 2008-04-24
>
> OS/400 Ver V5R3M0
>
>
> http_proxy_setauth(): entered
>
> New iconv() objects set, PostRem=1208. PostLoc=0. ProtRem=819.
> ProtLoc=0
>
> http_persist_open(): entered
>
> http_long_ParseURL(): entered
>
> DNS resolver retrans: 2
>
> DNS resolver retry : 2
>
> DNS resolver options: x'000001B6'
>
> DNS default domain: GR.XXXX.NET
>
> DNS server found: 111.111.2.22
>
> DNS server found: 111.111.111.1
>
> http_persist_post(): entered
>
> http_long_ParseURL(): entered
>
> do_post(): entered
>
> POST http://www.webservicex.net/CurrencyConvertor.asmx HTTP/1.1
>
> Host: www.webservicex.net
>
> User-Agent: http-api/1.23
>
> Content-Type: text/xml; charset=utf-8
>
> SOAPAction: http://www.webserviceX.NET/ConversionRate
>
> Expect: 100-continue
>
> Content-Length: 394
>
>
>
> recvresp(): entered
>
> HTTP/1.1 100 Continue
>
> Via: 1.1 HBPRX
>
>
>
> SetError() #13: HTTP/1.1 100 Continue
>
> senddoc(): entered
>
> <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" <soap:Body>
> <ConversionRate xmlns="http://www.webserviceX.NET/">
> <FromCurrency>CAD</FromCurrency> <ToCurrency>USD</ToCurrency>
> </ConversionRate></soap:Body></soap:Envelope>
>
> recvresp(): entered
>
> HTTP/1.1 400 Bad Request
>
> Via: 1.1 HBPRX
>
> Connection: Keep-Alive
>
> Proxy-Connection: Keep-Alive
>
> Content-Length: 0
>
> Date: Tue, 30 Jun 2009 12:22:34 GMT
>
> Server: Microsoft-IIS/6.0
>
> X-Powered-By: ASP.NET
>
> X-AspNet-Version: 2.0.50727
>
> Cache-Control: private
>
>
>
> SetError() #13: HTTP/1.1 400 Bad Request
>
> recvdoc parms: identity 0
>
> header_load_cookies() entered
>
> recvdoc(): entered
>
> SetError() #0:
>
> SetError() #13: HTTP/1.1 400 Bad Request
>
> http_close(): entered
>
> References
>
> 1. http://www.webservicex.net/
>
>
>
> ------------------------------------------------------------------------
>
> -----------------------------------------------------------------------
> 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
-----------------------------------------------------------------------