[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



Sorry, My first request should have included the question.

I am being told to


1.      Get a RequestData Object by using GetRequest/GetRequestByRequestId/GetRequestByOtherSystemId, and make sure it exists (RequestData.RequestId > 0)
2.      Modify the attribute fields of the RequestData object (don't  change the RequestId, ProblemSid, IncidentNum fields)
3.      Call  the UpdateRequest method and use the modified RequestData object as argument.

Do I need to parse out every field, then build the second request?  The attached code is where I am using the getrequest to query the status.

How would I reference the entire results, change one item, the send it to another webservice?
I guess I am just having a mental block with this since I have to wrap up the project by the end of the month.

Thanks,
Harold
0001  /TITLE        get    cityworks service request      CITY007
     H BNDDIR('QC2LE':'HTTPAPI') DFTACTGRP(*NO) ACTGRP(*NEW)
      /copy httpapi_h
     D VARYINGDATAOFFSET...
     D                 c                   const(2)
     D SOAP            s          32767A   varying
     D USERDATA        s          32767A   varying
     D*wait            s              1a
     D rc              s             10I 0
     D PCWSRID         S             10S 0
     D PCWSRST         S             20
     D PCWDISP         S             50
     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 Add_SOAPACTION  PR
     D   Header                    1024A   varying
     D   UserData                      *   value
0078 C******************************************
0078 C*  MAIN ROUTINE
0078 C******************************************
     C     *ENTRY        PLIST
     C                   PARM                    PCWSRID
     C                   PARM                    PCWSRST                        status
     C                   PARM                    PCWDISP                        dispatch to
     C                   PARM                    PCWCOMP                        Complete date
0079 C                   EXSR      RDCWSR                                       read CW prob table
     C                   EVAL      PCWSRST = Request.Status
     C                   EVAL      PCWDISP = Request.Dispatchto
     C                   EVAL      PCWCOMP = Request.CompDate
0079 C                   EVAL      *INLR=*ON
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
      *-----------------------------------------------------------------------------
0080 C     RDCWSR        BEGSR
     C                   MOVE      PCWSRID       SRID             10
      /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>';

       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(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
      *-----------------------------------------------------------------------------
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 = 'DispatchTo';
           Request.Dispatchto = value;

         When name = 'Status';
           Request.Status =  value;

         When name = 'DateTimeClosed';
           Request.CompDate = 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
         Header = 'SOAPAction: '
                         + 'http://www.azteca.com/cityworks/webservices/'
                         + 'GetRequestByRequestId'
                + x'0d25';
      /end-free
     P                 E
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------