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

RE: How can i get XML result after execution of 'http_url_post_xml'



The procedure Incoming is what will parse your XML. It is called each time an element is completed. It "automatically" receives certain parms as defined on the PR/PI.

In the example program, RATE is all that was required to be parsed. If you look in the program you will find a prototyped field being passed called rate as well as a global variable called rate. This was being filled when calling Incoming and the name of the element is ConversionRateResult.

EXAMPLE10 shows a more sophisticated but still simple version of the procedure (called xmlReply). As you can see the "rate" has been replaced by datastructure. Based on a really quick review of the XML returned in your case, this flat structure will work well. 

So, build a data structure for your return values. Pass the data structure to Incoming in place of rate. Create a large Select structure filling the different fields of the datastructure with your data. 
 

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Patrick Goovaerts
Sent: Tuesday, December 11, 2012 10:04 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: How can i get XML result after execution of 'http_url_post_xml'


Hi,

I was able to execute a webservice using basic authentication.
The ?debug? file shows that service is executed properly and result seems to
be ok

BUT?
How can I retrieve the returned XML data ?XML Result??


Regards.


FYI, herewith RPG app + Debugfile


RPG APP  (based on ?EXAMPLE18? of LIBHTTP)
      *  This is an example of calling a SOAP Web service w/HTTPAPI.
      *
      *  To Compile (requires V5R1):
      *     CRTBNDRPG PGM(CODASOAP) SRCFILE(libhttp/QRPGLESRC)
      *
      *  To Run:
      *     CALL CODASOAP
      *
      *
     H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')

     D CODASOAP        PR                  ExtPgm('CODASOAP')
     D*   Country1                     3A   const
     D*   Country2                     3A   const
     D*   Amount                      15P 5 const
     D CODASOAP        PI
     D*   Country1                     3A   const
     D*   Country2                     3A   const
     D*   Amount                      15P 5 const

      /copy httpapi_h

     D Incoming        PR
     D   rate                         8F
     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          32767A   varying
     D rc              s             10I 0
     D rate            s              8F
     D Result          s             12P 2

      /free

       http_debug(*ON);
       http_debug_file = '/home/pgo/debugpat.txt';

       http_XmlStripCRLF(*ON);

       SOAP = '<?xml version="1.0" encoding="utf-8"?>'
       +'<soapenv:Envelope xmlns:soapenv='
       +   '"http://schemas.xmlsoap.org/soap/envelope/"; '
       +'xmlns:web="http://www.coda.com/efinance/schemas/'
       +   'elementmaster/elementmaster-12.0/webservice" '
       +'xmlns:com="http://www.coda.com/efinance/schemas/common"; '
       +'xmlns:elem="http://www.coda.com/efinance/schemas/elementmaster";>'
       +'<soapenv:Header>'
       +'   <web:Options company="Q" user="INSTALL" />'
       +'</soapenv:Header>'
       +'<soapenv:Body>'
       +'   <web:GetRequest>'
       +'      <web:Key>'
       +'         <elem:CmpCode>Q</elem:CmpCode>'
       +'         <elem:Level>3</elem:Level>'
       +'         <elem:Code>000049</elem:Code>'
       +'      </web:Key>'
       +'   </web:GetRequest>'
       +'</soapenv:Body>'
       +'</soapenv:Envelope>';
         http_setAuth(HTTP_AUTH_BASIC:'USERID':'PASSWORD');
       rc = http_url_post_xml(

'http://Coda/coda/services/finance/elementmaster/elementmaster-12.0'
                         : %addr(SOAP) + 2
                         : %len(SOAP)
                         : *NULL
                         : %paddr(Incoming)
                         : %addr(rate)
                         : HTTP_TIMEOUT
                         : HTTP_USERAGENT
                         : 'text/xml'
                :
'uri-coda-webservice/12.000.0729/finance/ElementMaster/Get');

       if (rc <> 1);
          http_crash();
       else;
          dsply 'OK';
       endif;

       *inlr = *on;

      /end-free

     P Incoming        B
     D Incoming        PI
     D   rate                         8F
     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 atof            PR             8F   extproc('atof')
     D   string                        *   value options(*string)

      /free
          if (name = 'ConversionRateResult');
        //     rate = atof(value);
          endif;
      /end-free
     P                 E


DEBUG-resultfile
HTTPAPI Ver 1.23 released 2008-04-24
OS/400 Ver V7R1M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_setauth(): entered
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 3
DNS resolver retry  : 5
DNS resolver options: x'00000136'
DNS default domain: CLIPPERSUPPORT.BE
DNS server found: 10.0.0.180
DNS server found: 10.0.0.14
http_persist_post(): entered
http_long_ParseURL(): entered
do_post(): entered
POST /coda/services/finance/elementmaster/elementmaster-12.0 HTTP/1.1
Host: Coda
User-Agent: http-api/1.23
Content-Type: text/xml
SOAPAction: uri-coda-webservice/12.000.0729/finance/ElementMaster/Get
Expect: 100-continue
Content-Length: 635
Authorization: Basic SU5TVEFMTFxROk9BUw==


recvresp(): entered
HTTP/1.1 100 Continue


SetError() #13: HTTP/1.1 100 Continue
senddoc(): entered
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"; xmlns:web="
http://www.coda.com/efinance/schemas/elementmaster/elementmaster-12.0/webservice
" xmlns:com="http://www.coda.com/efinance/schemas/common"; xmlns:elem="
http://www.coda.com/efinance/schemas/elementmaster";><soapenv:Header>
<web:Options company="Q" user="INSTALL" /></soapenv:Header><soapenv:Body>
<web:GetRequest>      <web:Key>         <elem:CmpCode>Q</elem:CmpCode>
<elem:Level>3</elem:Level>         <elem:Code>000049</elem:Code>
</web:Key>   </web:GetRequest></soapenv:Body></soapenv:Envelope>
recvresp(): entered
HTTP/1.1 200 OK
Content-Length: 5188
Content-Type: text/xml;charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 11 Dec 2012 15:00:22 GMT


SetError() #13: HTTP/1.1 200 OK
recvdoc parms: identity 5188
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="
http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
"><soapenv:Body><webservice:GetResponse xmlns:webservice="
http://www.coda.com/efinance/schemas/elementmaster/elementmaster-12.0/webservice
" xmlns:com="http://www.coda.com/efinance/schemas/common"; xmlns:elm="
http://www.coda.com/efinance/schemas/elementmaster"; xmlns:udf="
http://www.coda.com/common/schemas/udfmaster
"><webservice:CmpCode>Q</webservice:CmpCode><webservice:Level>3</webservice:Level><webservice:Code>000049</webservice:Code><webservice:Element><elm:TimeStamp>2</elm:TimeStamp><elm:TaxesTimeStamp>2</elm:TaxesTimeStamp><elm:CmpCode>Q</elm:CmpCode><elm:Code>000049</elm:Code><elm:Level>3</elm:Level><elm:Name>AGEPORT
 AG.Y ESTIBADORES
PORTUARIOS</elm:Name><elm:ShortName>AGEPORT</elm:ShortName><elm:CurrencyCode>EUR</elm:CurrencyCode><elm:SubAnalyse>sometimes</elm:SubAnalyse><elm:TaxCode/>
<elm:AccountType>look_left</elm:AccountType><elm:DateAccountOpened>2012-07-31T00:00:00.000Z</elm:DateAccountOpened><elm:CompulsoryDescr>false</elm:CompulsoryDescr><elm:KeepTurnover>false</elm:KeepTurnover><elm:AccountSummary>AS-REL</elm:AccountSummary><elm:ElementStatus/>
<elm:ExternalValidation/><elm:MemoStatus/><elm:BalancingAccount/>
<elm:SubsLevel>0</elm:SubsLevel><elm:SubsElement/>
<elm:Matchable>true</elm:Matchable><elm:Summary>acct_level</elm:Summary><elm:Split>none</elm:Split><elm:Settlement/>
<elm:ForceDisperse>forcedisp</elm:ForceDisperse><elm:UserStatus/>
<elm:PayStatus>available</elm:PayStatus><elm:RecStatus>available</elm:RecStatus><elm:EnablePay>true</elm:EnablePay><elm:DefaultMedia/>
<elm:PaperMedia>false</elm:PaperMedia><elm:ElecMedia>true</elm:ElecMedia><elm:PayNumber>0</elm:PayNumber><elm:CustomerSupplier>true</elm:CustomerSupplier><elm:IsCustomer>true</elm:IsCustomer><elm:IsSupplier>true</elm:IsSupplier><elm:DiscountEnable>no</elm:DiscountEnable><elm:TaxMethod>net</elm:TaxMethod><elm:Terms>D030</elm:Terms><elm:TaxAdjustment>false</elm:TaxAdjustment><elm:TaxRepESL>false</elm:TaxRepESL><elm:TaxRepIntra>false</elm:TaxRepIntra><elm:VAT/>
<elm:Ten99>false</elm:Ten99><elm:FederalTax/><elm:SocialSecurity/>
<elm:Ten99Code/><elm:SecondTIN>false</elm:SecondTIN><elm:SIC/>
<elm:CreditManager/><elm:CreditRating/>
<elm:CreditRatingDate>2012-07-31T00:00:00.000Z</elm:CreditRatingDate><elm:CreditReference/>
<elm:CreditAgency/><elm:PaymentIndex/>
<elm:ForceCreditLimit>false</elm:ForceCreditLimit><elm:IndirectCode/>
<elm:CreditLimit>0.00</elm:CreditLimit><elm:CreditLimitCurrency>credit_lim_home</elm:CreditLimitCurrency><elm:ArcRecon>arc_no_allow_override</elm:ArcRecon><elm:ArcPaid>arc_no_allow_override</elm:ArcPaid><elm:Shared>false</elm:Shared><elm:PostedTo>false</elm:PostedTo><elm:PromptForAsset>false</elm:PromptForAsset><elm:AssetCategory/>
<elm:ProcOrders/><elm:ProcRequisitions/>
<elm:BillingAllowPrinting>false</elm:BillingAllowPrinting><elm:BillingTransmitPDF>false</elm:BillingTransmitPDF><elm:BillingTransmitXML>false</elm:BillingTransmitXML><elm:BillingSIProForma/>
<elm:BillingSIFinal/><elm:BillingCNProForma/><elm:BillingCNFinal/>
<elm:CreateDate>2012-09-18T00:00:00.000Z</elm:CreateDate><elm:ModifyDate>2012-11-16T00:00:00.000Z</elm:ModifyDate><elm:User>INSTALL</elm:User><elm:PunchoutCode/>
<elm:PunchoutMarketplace>false</elm:PunchoutMarketplace><elm:PunchoutUrl/>
<elm:PunchoutDomain/>
<elm:PunchoutEncoding>null</elm:PunchoutEncoding><elm:PunchoutUser/>
<elm:PunchoutPassword/><elm:PunchoutItemDetailsCode/>
<elm:AutoReceipt>false</elm:AutoReceipt><elm:ProcStatus>false</elm:ProcStatus><elm:ToleranceCode/>
<elm:MatchingOffset>0</elm:MatchingOffset><elm:ProcTransLimit>0</elm:ProcTransLimit><elm:ProcCalloffs/>
<elm:ProcGRNs/><elm:ProcReturns/><elm:BillingOutputDevice/><elm:EUVATCode/>
<elm:Translations><elm:List/></elm:Translations><elm:LongName/>
<elm:Quantities/><elm:Discounts/>
<elm:Addresses><elm:Address><elm:DefaultAddress>true</elm:DefaultAddress><elm:Tag>1</elm:Tag><elm:Name>AGEPORT
 AG.Y ESTIBADORES PORTUARIOS</elm:Name><elm:Address1>MIRADOR APT.401,ENSACHE
BELLA VISTA</elm:Address1><elm:Address2/><elm:Address3/><elm:Address4/>
<elm:Address5/><elm:Address6>P.O.BOX 22205</elm:Address6><elm:PostCode/>
<elm:Tel>0018095357758</elm:Tel><elm:Fax>0018095354116</elm:Fax><elm:Country>DO</elm:Country><elm:Language>EN</elm:Language><elm:Category>LEGAL</elm:Category><elm:EMail>
ageport@xxxxxxxxxxxxxx</elm:EMail></elm:Address><elm:Address><elm:DefaultAddress>false</elm:DefaultAddress><elm:Tag>2</elm:Tag><elm:Name>AGEPORT
 AG.Y ESTIBADORES PORTUARIOS</elm:Name><elm:Address1>
MDIAZ@xxxxxxxxxxx</elm:Address1><elm:Address2/><elm:Address3/>
<elm:Address4/><elm:Address5/><elm:Address6/><elm:PostCode/><elm:Tel/>
<elm:Fax/><elm:Country/>
<elm:Language>EN</elm:Language><elm:Category>EMAIL</elm:Category><elm:EMail/>
</elm:Address></elm:Addresses><elm:Banks/><elm:Comments/>
<elm:Groups><elm:GroupCode>3REL</elm:GroupCode><elm:GroupCode>3K</elm:GroupCode></elm:Groups><elm:Medias/>
<elm:LeftRules/><elm:RightRules/><elm:Mnemonics/>
<elm:PunchoutAdvancedParams/><elm:OutputDevices/>
</webservice:Element></webservice:GetResponse></soapenv:Body></soapenv:Envelope
>
http_close(): entered


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