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

Re: HTTPAPI - Parsing Response



Lucille,

The response is not coming back in plain XML format, so you will need to do a bit more coding. The response is coming back in "multipart/related" format, which is a MIME format. You will need to write code to split out the different parts from that MIME format and extract the XML from it.

So please do not use http_url_post_xml(), here, as it is not plain XML format.

Instead, use http_url_post() or http_url_post_raw(), depending on how you'd like to code it, and then extract the XML from the multipart/related format, and then you can either pass that resulting XML to http_parse_xml_string() or one of the RPG XML opcodes like XML-INTO or XML-SAX.

Good luck!
-SK

On 11/30/2015 10:07 PM, Pinto, Lucille wrote:
    I use HTTP_URL_POST_XML to send and receive information.


      rc = http_url_post_xml(

             %trim(Endpoint)

             : %addr(SOAP) + 2

             : %len(SOAP)

             : *NULL

             : %paddr(Incoming)

             : %addr(trnt)

             : HTTP_TIMEOUT

             : HTTP_USERAGENT

             : 'text/xml; charset=utf-8');


      // Check for an error.

      if (rc <> 1);

        RETCD  = '2';

        http_crash();

      endif;

     /end-free


    P Incoming        B

    D Incoming        PI

    D UserData                        *   value

    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)


    if name = 'status';

    eval trnt = value;

    dsply trnt;

    endif;


    RC is always set to -1 with an error SetError() #66: XML parse failed
    at line 1, col 0: syntax error


    The response is


    HTTP/1.1 200 OK

    Date: Tue, 01 Dec 2015 02:31:04 GMT

    Content-Type: multipart/related; type="application/xop+xml";
    boundary="uuid:86f14eca-4f2d-4056-ace9-663654ee9247";
    start="<root.message@xxxxxxxxxxxxxx>"; start-info="text/xml"

    Content-Length: 2354

    awd-content: D=90012

    Connection: close


    --uuid:86f14eca-4f2d-4056-ace9-663654ee9247

    Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"

    Content-Transfer-Encoding: binary

    Content-ID: <root.message@xxxxxxxxxxxxxx>


    <soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><SOAP-ENV:Header
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><soap:Body>
    <ns2:createObjectsResponse
    xmlns:ns2="http://ws.processing.dstawd.com/";><createObjectsResponse><wo
    rkInstance assignedTo="SYSTEM" id="2015-12-01-13.31.04.707860T01"
    instanceType="transaction"
    permission="Update"><createTime>2015-12-01T13:31:04:707860+11:00</creat
    eTime><fieldValues><fieldValue name="VIP">N</fieldValue><fieldValue
    name="amount">0.0000</fieldValue><fieldValue
    name="amountType"></fieldValue><fieldValue
    name="AGBR">04</fieldValue><fieldValue
    name="AGNO">20979</fieldValue><fieldValue
    name="BEML">lpinto@xxxxxxxxxx</fieldValue><fieldValue
    name="BOUT">EM</fieldValue><fieldValue
    name="CNUM">900011</fieldValue><fieldValue
    name="COUT">PT</fieldValue><fieldValue
    name="CTGR">CRP</fieldValue><fieldValue
    name="DECD">20181031</fieldValue><fieldValue
    name="EXTP">000000500.00</fieldValue><fieldValue
    name="INCD">20141031</fieldValue><fieldValue
    name="NCET">A</fieldValue><fieldValue
    name="NETR">00000</fieldValue><fieldValue
    name="PBCH">02</fieldValue><fieldValue
    name="PNUM">0582896</fieldValue><fieldValue
    name="PSTA">A</fieldValue><fieldValue
    name="PTYP">015</fieldValue><fieldValue
    name="RSKD">20151120</fieldValue><fieldValue
    name="RTYP">2</fieldValue><fieldValue
    name="TRTY">RENEWAL</fieldValue><fieldValue
    name="PEXD">20151031</fieldValue><fieldValue name="INSR">LUCILLE
    TEST</fieldValue><fieldValue name="BROK">AON
    RISKSER</fieldValue></fieldValues><businessArea>POLICYMGMT</businessAre
    a><type>RENEWAL</type><customScreen>GENERIC.CSD</customScreen><iconName
    ></iconName><externalSystems><externalSystem><externalDLL></externalDLL
    ><externalHost></externalHost><externalParameter></externalParameter><e
    xternalProcedure></externalProcedure><order>0</order></externalSystem><
    /externalSystems><lockedBy>SYSTEM</lockedBy><status>CREATED</status><qu
    eue>SYSTEM</queue><priority>999</priority><priorityIncrease>0</priority
    Increase></workInstance><immediateRelationships/></createObjectsRespons
    e></ns2:createObjectsResponse></soap:Body></soap:Envelope>

    --uuid:86f14eca-4f2d-4056-ace9-663654ee9247--



-----------------------------------------------------------------------
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
-----------------------------------------------------------------------