[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Webservice getCitiesByCountry



Hello

I'm trying to use HTTPAPI to consume this webservice:

http://www.webservicex.net/globalweather.asmx?op=GetCitiesByCountry

This is my little program:

     H DFTACTGRP(*NO) ACTGRP(*new) BNDDIR('HTTPAPI')

     W*E CRTBNDRPG  get_cities   srcfile(*libl/qrpglesrc)
     W*E+       DBGVIEW(*SOURCE)
     W*E+       REPLACE(*YES)
     E*W

      /copy HTTPAPI_H

     d VARYINGDATAOFFSET...
     d                 c                     const(2)
     d SOAP            s           1024a     varying
     d rc              s             10i 0
     d c_COUNTRY       s             20a     varying

      /free

        c_COUNTRY = 'Italy';

        SOAP = '<soap:Envelope'
             + ' xmlns:soap="http://www.w3.org/2003/05/soap-envelope'
             + ' xmlns:web="http://www.webserviceX.NET";>'
             + ' <soap:Header/>'
             + '   <soap:Body>'
             + '      <web:GetCitiesByCountry>'
             + '          <web:CountryName>' + c_Country
             + ' <web:CountryName>'
             + '      </web:GetCitiesByCountry>'
             + '   </soap:Body>'
             + '</soap:Envelope>';


        // http_setCCSIDs(1208 : 0);
           http_debug(*ON:'/jgvtmp/httpapi_debug1.txt');

           rc = http_post('http://www.webserviceX.NET/globalweather.asmx'
                            + '/GetCitiesByCountry'
                            : %addr(SOAP) + VARYINGDATAOFFSET
                            : %len(SOAP)
                            : '/jgvtmp/CitiesByCountry.txt'
                            : HTTP_TIMEOUT
                            : HTTP_USERAGENT
                            : 'text/xml; charset=utf-8'
                 : 'urn."http://www.webserviceX.NET/GetCitiesByCountry";');

           if (rc <> 1);
             http_crash();
           endif;


           *inlr = *on;

      /end-free


And this is the resulting debug-file:


HTTPAPI Ver 1.24 released 2012-01-23
OS/400 Ver V6R1M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_url_post(): entered
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry  : 2
DNS resolver options: x'00000136'
DNS default domain: WEMAG.ch
DNS server found: 195.186.1.110
http_persist_post(): entered
http_persist_req(POST) entered.
http_long_ParseURL(): entered
do_oper(POST): entered
There are 0 cookies in the cache
POST /globalweather.asmx/GetCitiesByCountry HTTP/1.1
Host: www.webserviceX.NET
User-Agent: http-api/1.24
Content-Type: text/xml; charset=utf-8
SOAPAction: urn."http://www.webserviceX.NET/GetCitiesByCountry";
Content-Length: 277


senddoc(): entered
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope xmlns:web="http://www.webserviceX.NET";> <soap:Header/> <soap:Body> <web:GetCitiesByCountry> <web:CountryName>Italy <web:CountryName> </web:GetCitiesByCountry> </soap:Body></soap:Envelope>
recvresp(): entered
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Length: 236
Content-Type: text/plain; charset=utf-8
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 04 Jul 2014 12:58:25 GMT


SetError() #13: HTTP/1.1 500 Internal Server Error
recvresp(): end with 500
recvdoc parms: identity 236
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
System.InvalidOperationException: Request format is invalid: text/xml; charset=utf-8.
   at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

SetError() #13: HTTP/1.1 500 Internal Server Error
http_close(): entered

What am I doing wrong?

Best regards

Jan




-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------