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

RE: using the response from one service to make another request- need a little Guidance



Making some progress
At the suggestion of a friend I'm moving the results into an array, then using that to post to the other webservice

I'm ending up with the headers at the end (see debug).  How can I populate the array with the headers in the correct sequence or removed?

</web:CustomerCallData>
<web:CustomerCalls>
</web:CustomerCalls>
<web:GetRequestByRequestIdResult>
</web:GetRequestByRequestIdResult>
<web:GetRequestByRequestIdResponse>
</web:GetRequestByRequestIdResponse>
<web:soap:Body>
</web:soap:Body>
<web:soap:Envelope>
</web:soap:Envelope>



    http_xproc( HTTP_POINT_ADDL_HEADER
                 : %paddr(Add_SOAPACTION) );

       rc = http_url_post_xml(
                  'http://10.1.1.15/cwwebservices/CityworksWebService.asmx'
                         : %addr(SOAP) + VARYINGDATAOFFSET
                         : %len(SOAP)
                         : *NULL
                         : %paddr(MapXmlData)
                         : %addr(UserData)
                         : HTTP_TIMEOUT
                         : HTTP_USERAGENT
                         : 'text/xml; charset=UTF-8' );
     P MapXmlData      B
     D MapXmlData      PI
     D   UserData                      *
     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

       Select;

         When name <> 'Status';
         x=x+1;
         RECX(x) = '<web:' + %trim(name) + '>' +
                   %trim(value) + '</web:' + %trim(name) + '>';

         When name = 'Status';
         x=x+1;
         RECX(x) = '<web:' + %trim(name) + '>Closed' +
                   '</web:' + %trim(name) + '>';

       Endsl;

      /end-free
0001  /TITLE        get    cityworks service request      CITY011
     H BNDDIR('QC2LE':'HTTPAPI') DFTACTGRP(*NO) ACTGRP(*NEW)
      /copy httpapi_h
     D VARYINGDATAOFFSET...
     D                 c                   const(2)
     D RECX            s            500    DIM(500)
     D SOAP            s          32767A   varying
     D USERDATA        s          32767A   varying
     D*wait            s              1a
     D rc              s             10I 0
     D x               S              3S 0 inz(0)
     D PCWSRID         S             10S 0
     D PCWSRST         S             20
     D URESULT         S             10
     D HEAD            S             10
     D PCWCOMP         S             28
     DTimStp           S               Z   inz(*sys)
     D Request         DS                  qualified
     D   Dispatchto                  50A
     D   Status                      20A
     D   CompDate                    28A

     D MapXmlData      PR
     D   UserData                      *
     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 MapXmlres       PR
     D   UserData                      *
     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 Add_SOAPACTION  PR
     D   Header                    1024A   varying
     D   UserData                      *   value
     D Add_SOAPACTIO2  PR
     D   Header                    1024A   varying
     D   UserData                      *   value
0078 C******************************************
0078 C*  MAIN ROUTINE
0078 C******************************************
     C     *ENTRY        PLIST
     C                   PARM                    PCWSRID
0079 C                   EXSR      RDCWSR                                       read CW prob table
0079 C                   if        PCWSRID <> 9999999999                        error on prev
0079 C                   EXSR      UPCWSR                                       read CW prob table
0079 C                   if        URESULT <> 'true'                            error on prev
0079 C                   eval      PCWSRID  = 9999999999
0079 C                   endif                                                  read CW prob table
0079 C                   endif                                                  read CW prob table
0079 C                   EVAL      *INLR=*ON
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
0080 C     RDCWSR        BEGSR
     C                   MOVE      PCWSRID       SRID             10
     C                   EVAL      HEAD = 'first'
      /free

       // Note:  http_debug(*ON/*OFF) can be used to turn debugging
       //        on and off.  When debugging is turned on, diagnostic
       //        info is written to an IFS file named
       //        /tmp/httpapi_debug.txt

       http_debug(*ON);

       // Note:  http_XmlStripCRLF(*ON/*OFF) controls whether or not
       //        the XML parser removes CR and LF characters from the
       //        Xml data that's passed to your 'Incoming' procedure.

       http_XmlStripCRLF(*ON);

       SOAP =
        '<soapenv:Envelope'
       +' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";'
       +' xmlns:web="http://www.azteca.com/cityworks/webservices";>'
       +'<soapenv:Header>'
       +'<web:CWAuthHeader>'
       +' <!--Optional:-->'
       +' <web:UserName>CWWEB</web:UserName>'
       +' <!--Optional:-->'
       +' <web:Password>CWWEB</web:Password>'
       +'</web:CWAuthHeader>'
       +'</soapenv:Header>'
       +'<soapenv:Body>'
       +'<web:GetRequestByRequestId>'
       +'<web:requestId>' + SRID + '</web:requestId>'
       +'</web:GetRequestByRequestId>'
       +'</soapenv:Body>'
       +'</soapenv:Envelope>';

       

       //  This tells HTTPAPI to call our subprocedure (in this example,
       //  the subprocedure is name ADD_SOAPACTION) when assembling the
       //  HTTP headers to send to the remote server.

       http_xproc( HTTP_POINT_ADDL_HEADER
                 : %paddr(Add_SOAPACTION) );

       rc = http_url_post_xml(
                  'http://10.1.1.15/cwwebservices/CityworksWebService.asmx'
                         : %addr(SOAP) + VARYINGDATAOFFSET
                         : %len(SOAP)
                         : *NULL
                         : %paddr(MapXmlData)
                         : %addr(UserData)
                         : HTTP_TIMEOUT
                         : HTTP_USERAGENT
                         : 'text/xml; charset=UTF-8' );
        if (rc <> 1);
          http_crash();
0079      PCWSRID  = 9999999999;
          *INLR = *On;
          Return;
       else;
       endif;


      /end-free
0080 C                   ENDSR
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
0080 C     UPCWSR        BEGSR
     C                   EVAL      HEAD = 'second'
      /free

       // Note:  http_debug(*ON/*OFF) can be used to turn debugging
       //        on and off.  When debugging is turned on, diagnostic
       //        info is written to an IFS file named
       //        /tmp/httpapi_debug.txt

       http_debug(*ON);

       // Note:  http_XmlStripCRLF(*ON/*OFF) controls whether or not
       //        the XML parser removes CR and LF characters from the
       //        Xml data that's passed to your 'Incoming' procedure.

       http_XmlStripCRLF(*ON);

       SOAP =
        '<soapenv:Envelope'
       +' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";'
       +' xmlns:web="http://www.azteca.com/cityworks/webservices";>'
       +'<soapenv:Header>'
       +'<web:CWAuthHeader>'
       +' <!--Optional:-->'
       +' <web:UserName>CWWEB</web:UserName>'
       +' <!--Optional:-->'
       +' <web:Password>CWWEB</web:Password>'
       +'</web:CWAuthHeader>'
       +'</soapenv:Header>'
       +'<soapenv:Body>'
       +'<web:UpateRequest>'
       +'<web:ReqData>';

           x=0;
           dou RECX(x) <= *blank;
              x=x+1;
              SOAP = SOAP + %trim(RECX(x));
              enddo;

       SOAP = SOAP
       +'</web:reqdata>'
       +'</web:UpdateRequest>'
       +'</soapenv:Body>'
       +'</soapenv:Envelope>';

       http_debug(*ON);


       //  This tells HTTPAPI to call our subprocedure (in this example,
       //  the subprocedure is name ADD_SOAPACTION) when assembling the
       //  HTTP headers to send to the remote server.

       http_xproc( HTTP_POINT_ADDL_HEADER
                 : %paddr(Add_SOAPACTION) );

       rc = http_url_post_xml(
                  'http://10.1.1.15/cwwebservices/CityworksWebService.asmx'
                         : %addr(SOAP) + VARYINGDATAOFFSET
                         : %len(SOAP)
                         : *NULL
                         : %paddr(MapXmlres)
                         : %addr(UserData)
                         : HTTP_TIMEOUT
                         : HTTP_USERAGENT
                         : 'text/xml; charset=UTF-8' );
        if (rc <> 1);
          http_crash();
0079      PCWSRID  = 9999999999;
          *INLR = *On;
          Return;
       else;
       endif;


      /end-free
0080 C                   ENDSR
      *-----------------------------------------------------------------------------
0078  ******************************************************************************
      *-----------------------------------------------------------------------------
0078 C******************************************
     P MapXmlData      B
     D MapXmlData      PI
     D   UserData                      *
     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

       Select;

         When name <> 'Status';
         x=x+1;
         RECX(x) = '<web:' + %trim(name) + '>' +
                   %trim(value) + '</web:' + %trim(name) + '>';

         When name = 'Status';
         x=x+1;
         RECX(x) = '<web:' + %trim(name) + '>Closed' +
                   '</web:' + %trim(name) + '>';

       Endsl;

      /end-free
     P                 E
0078 C******************************************
     P MapXmlres       B
     D MapXmlres       PI
     D   UserData                      *
     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

       Select;


         When name = 'UpdateRequestResult';
         URESULT = value;

       Endsl;

      /end-free
     P                 E

      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      * HTTPAPI will call this (because we set it with http_xproc)
      * just before sending the HTTP headers to the remote server.
      * This procedure lets us add any header we like to the
      * HTTP request.
      *
      * In this example, I'll use it to supply the SoapAction:
      * header.  This way, I can supply a SOAPAction that's up to
      * 1024 characters long.
      *
      * NOTE: Make sure you leave off the SOAPAction header on the
      *       HTTP_url_post_xml, above, otherwise you'll send two
      *       of them!
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P Add_SOAPACTION  B
     D Add_SOAPACTION  PI
     D   Header                    1024A   varying
     D   UserData                      *   value
      /free
       Select;

         When HEAD  = 'first';
         Header = 'SOAPAction: '
                         + 'http://www.azteca.com/cityworks/webservices/'
                         + 'GetRequestByRequestId'
                + x'0d25';
         When HEAD  = 'second';
         Header = 'SOAPAction: '
                         + 'http://www.azteca.com/cityworks/webservices/'
                         + 'UpdateRequest'
                + x'0d25';
       Endsl;
      /end-free
     P                 E
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:web="http://www.azteca.com/cityworks/webservices";>
<soapenv:Header>
<web:CWAuthHeader> 
<!--Optional:--> 
<web:UserName>CWWEB</web:UserName>
 <!--Optional:--> 
<web:Password>CWWEB</web:Password>
</web:CWAuthHeader>
</soapenv:Header><soapenv:Body>
<web:UpateRequest><web:ReqData>
<web:RequestId>824748</web:RequestId>
<web:DomainId>1</web:DomainId>
<web:ProjectSid>-9999</web:ProjectSid>
<web:ProblemCode>CONNECT SERVICE</web:ProblemCode>
<web:Details>OWNERS 502269         Meter - Residential  - City water and Sewer      - 001 Dwelling units</web:Details>
<web:ReqCategory>FS</web:ReqCategory>
<web:Description>On - Read</web:Description>
<web:Priority>3</web:Priority>
<web:SRX>0</web:SRX>
<web:SRY>0</web:SRY>
<web:ProblemSid>10196</web:ProblemSid>
<web:ReqCustFieldCatId>6011</web:ReqCustFieldCatId>
<web:ProbAddress>2112 JEFF DAVIS ST.</web:ProbAddress>
<web:ProbCity>MACON</web:ProbCity>
<web:ProbZip></web:ProbZip>
<web:ProbAddType>A</web:ProbAddType>
<web:InitiatedBy>HJR via CITYWOSR - MWACIS</web:InitiatedBy>
<web:DateTimeInit>2009-05-05T17:18:29</web:DateTimeInit>
<web:SubmitToPager></web:SubmitToPager>
<web:SubmitToPhone></web:SubmitToPhone>
<web:SubmitTo>-9999</web:SubmitTo>
<web:SubmitToEmail></web:SubmitToEmail>
<web:ClosedBy>MWA</web:ClosedBy>
<web:DateTimeClosed>0001-01-01T00:00:00</web:DateTimeClosed>
<web:WorkOrderId></web:WorkOrderId>
<web:ProjectName></web:ProjectName>
<web:DateSubmitTo>2009-05-05T17:18:29</web:DateSubmitTo>
<web:SubmitToOpenBy></web:SubmitToOpenBy>
<web:DateSubmitToOpen>0001-01-01T00:00:00</web:DateSubmitToOpen>
<web:DispatchTo></web:DispatchTo>
<web:DateDispatchTo>0001-01-01T00:00:00</web:DateDispatchTo>
<web:DispatchOpenBy></web:DispatchOpenBy>
<web:DateDispatchOpen>0001-01-01T00:00:00</web:DateDispatchOpen>
<web:MapPage></web:MapPage>
<web:Shop></web:Shop>
<web:Status>Closed</web:Status>
<web:Cancel>false</web:Cancel>
<web:CancelledBy></web:CancelledBy>
<web:DateCancelled>0001-01-01T00:00:00</web:DateCancelled>
<web:LaborCost>0</web:LaborCost>
<web:FieldInvtDone>false</web:FieldInvtDone>
<web:DateInvtDone>0001-01-01T00:00:00</web:DateInvtDone>
<web:WONeeded>false</web:WONeeded>
<web:Excursion>false</web:Excursion>
<web:TileNo></web:TileNo>
<web:PrjCompleteDate>2009-04-29T21:30:00</web:PrjCompleteDate>
<web:Text1></web:Text1>
<web:Text2></web:Text2>
<web:Text3></web:Text3>
<web:Text4></web:Text4>
<web:Text5></web:Text5>
<web:Text6></web:Text6>
<web:Text7></web:Text7>
<web:Text8></web:Text8>
<web:Text9></web:Text9>
<web:Text10></web:Text10>
<web:Text11></web:Text11>
<web:Text12></web:Text12>
<web:Text13></web:Text13>
<web:Text14></web:Text14>
<web:Text15></web:Text15>
<web:Text16></web:Text16>
<web:Text17></web:Text17>
<web:Text18></web:Text18>
<web:Text19></web:Text19>
<web:Text20></web:Text20>
<web:OtherSystemId>1225423</web:OtherSystemId>
<web:OtherSystemStatus></web:OtherSystemStatus>
<web:OtherSystemCode></web:OtherSystemCode>
<web:OtherSystemDesc></web:OtherSystemDesc>
<web:OtherSystemDesc2></web:OtherSystemDesc2>
<web:ProbAptNum></web:ProbAptNum>
<web:ProbLandmark></web:ProbLandmark>
<web:ProbDistrict></web:ProbDistrict>
<web:ProbState></web:ProbState>
<web:ProbLocation></web:ProbLocation>
<web:CancelReason></web:CancelReason>
<web:Num1>-9999</web:Num1>
<web:Num2>-9999</web:Num2>
<web:Num3>-9999</web:Num3>
<web:Num4>-9999</web:Num4>
<web:Num5>-9999</web:Num5>
<web:Date1>0001-01-01T00:00:00</web:Date1>
<web:Date2>0001-01-01T00:00:00</web:Date2>
<web:Date3>0001-01-01T00:00:00</web:Date3>
<web:Date4>0001-01-01T00:00:00</web:Date4>
<web:Date5>0001-01-01T00:00:00</web:Date5>
<web:InitiatedByApp>MWACIS</web:InitiatedByApp>
<web:Resolution></web:Resolution>
<web:StreetName></web:StreetName>
<web:LockedByDesktopUser></web:LockedByDesktopUser>
<web:Comments>OWNERS 502269         Meter - Residential  - City water and Sewer      - 001 Dwelling units</web:Comments>

<web:IncidentNum>26752</web:IncidentNum>
<web:RequestId>824748</web:RequestId>
<web:FirstName></web:FirstName>
<web:LastName>UNKNOWN</web:LastName>
<web:Title></web:Title>
<web:MiddleInitial></web:MiddleInitial>
<web:AcctNum>040374</web:AcctNum>
<web:CCX>0</web:CCX>
<web:CCY>0</web:CCY>
<web:AptNum></web:AptNum>
<web:CustAddress>2112 JEFF DAVIS ST.</web:CustAddress>
<web:CustCity>MACON</web:CustCity>
<web:CustZip></web:CustZip>
<web:CustAddType>A</web:CustAddType>
<web:HomePhone>4787432830</web:HomePhone>
<web:DateTimeCall>2009-05-05T17:18:29</web:DateTimeCall>
<web:OtherPhone></web:OtherPhone>
<web:Email></web:Email>
<web:WorkPhone></web:WorkPhone>
<web:IsResident>true</web:IsResident>
<web:IsFollowUpCall>false</web:IsFollowUpCall>
<web:CallerType>?</web:CallerType>
<web:Comments></web:Comments>
<web:CustContact>false</web:CustContact>
<web:DateTimeContact>0001-01-01T00:00:00</web:DateTimeContact>
<web:CustCallback>false</web:CustCallback>
<web:DateTimeCallback>0001-01-01T00:00:00</web:DateTimeCallback>
<web:ProbDetails>ON AND READ ON AND READ OWNERS 502269         Meter - Residential  - City water and Sewer      - 001 Dwelling units</web:ProbDetails>
<web:CellPhone></web:CellPhone>
<web:Fax></web:Fax>
<web:CustDistrict>5</web:CustDistrict>
<web:CustState>GA</web:CustState>
<web:Text1>?</web:Text1>
<web:Text2>?</web:Text2>
<web:Text3>?</web:Text3>
<web:Text4>?</web:Text4>
<web:Text5>?</web:Text5>
<web:CustomerCallData>
</web:CustomerCallData>
<web:CustomerCalls>
</web:CustomerCalls>
<web:GetRequestByRequestIdResult>
</web:GetRequestByRequestIdResult>
<web:GetRequestByRequestIdResponse>
</web:GetRequestByRequestIdResponse>
<web:soap:Body>
</web:soap:Body>
<web:soap:Envelope>
</web:soap:Envelope>
</web:reqdata>
</web:UpdateRequest>
</soapenv:Body>
</soapenv:Envelope>
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------