Rui Leming
Rui Leming

Reputation: 61

sage x3 3rd Party Webservice XML

I'm trying to make a call to a 3rd party webservice using Sage X3 scripts, I'm using the func ASYRWEBSER.EXEC_HTTP which is working fine and it's calling the webservice and receiving the answer

The Answer:

<s:Envelope
    xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <s:Body>
        <CreateShipmentResponse
            xmlns=\"http://tempuri.org/\">
            <CreateShipmentResult
                xmlns:a=\"http://schemas.datacontract.org/2004/07/CTTExpressoWS\"
                xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">
                <a:ErrorsList/>
                <a:ShipmentData>
                    <a:ShipmentDataOutput>
                        <a:ClientReference>teste</a:ClientReference>
                        <a:DocumentsList>
</a:DocumentsList>
                        <a:FirstObject>DB112320353PT</a:FirstObject>
                        <a:LabelList>
                            <a:LabelData>
                                <a:BestEncoding>65001</a:BestEncoding>
                                <a:FileName>ETI</a:FileName>
                                <a:Label>^XA&#xD;\n</a:Label>
                            </a:LabelData>
                        </a:LabelList>
                        <a:LastObject>DB112320353PT</a:LastObject>
                        <a:OriginalObjectID i:nil=\"true\"/>
                    </a:ShipmentDataOutput>
                </a:ShipmentData>
                <a:Status>Success</a:Status>
            </CreateShipmentResult>
        </CreateShipmentResponse>
    </s:Body>
</s:Envelope>

My problem is that I don't know how to get the XML fields I need in X3 Scripts, can anyone point me in the right direction?

I need to get the <a:LastObject>, the <a:Status> and the <a:LabelList><a:LabelData> of the response.

Upvotes: 0

Views: 610

Answers (1)

Roberto Nascimento
Roberto Nascimento

Reputation: 1

Maybe I am a little late, but in case you did not solve it yet: You get the response in a clbfile variable (last parameter of EXEC_HTTP - Funprog EXEC_HTTP(HEADERCOD, HEADERVAL, DATA, RESHEAD, RESBODY)).

Here are a few options to parse the RESBODY clbfile:

  1. Parse the content directly in 4gl.
  2. Module in nodeJS (custom module)
  3. Executable called by "System" instruction

Upvotes: 0

Related Questions