Multiple structures returned on a SOAP call

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
davidb
Posts: 2
Joined: Tue May 31, 2022 3:48 pm

Multiple structures returned on a SOAP call

Post by davidb »

Hello, I'm using httpapi, http_url_post_xml to post to a service that's returning two structures, the first structure typically contains a basic status of the call, which may contain text such as 'no records returned' <soap:Envelope>...</soap:Envelope>. This is followed in the same return by another structure, which is the data I expect to be returned from my call, in <LicensingReportProcessResult> ..</LicensingReportProcessResult>.

This second causes an xml parser error on the call being made. If I make the call using SOAPUI, the second structure is returned as an attachment. I tried loading the return into a file using http_url_post into an IFS file, then http_parse_xml_stmf , but parsing that file gives the same error.

The size of the second structure can be very large, much greater than 64k. I'm looking for advice on the most efficient way to handle this return. Should I be using a different method, is there a way to split out that second structure into a separate file, similar to how SOAPUI makes it an attachment?

Any advice greatly appreciated.

Here's a typical layout of the raw returned content. Second structure in this example contains no real data, but the structure is correct. When data is returned, It's normally somewhere in the order of 10mb.


HTTP/1.1 200 OK
Date: Fri, 27 May 2022 16:08:14 GMT
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:eacca707-56d7-4a7f-983d-34448fdd87a9"; start="<root.message@cxf.apache.org>"; start-info="text/xml"
Transfer-Encoding: chunked
Connection: keep-alive
Server: Apache/2.4.6 (Red Hat)


--uuid:eacca707-56d7-4a7f-983d-34448fdd87a9
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelop ... rtResponse xmlns="https://anther-service.com/my-ws"><aler ... op:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:4d7b1558-454d-40ce-894c-e15b17791ec7-5550@my-services.com"/></alertsReport></alertsReport></receiveSpecificReportResponse></soap:Body></soap:Envelope>
--uuid:eacca707-56d7-4a7f-983d-34448fdd87a9
Content-Type: null
Content-Transfer-Encoding: binary
Content-ID: <4d7b1558-454d-40ce-894c-e15b17791ec7-5550@my-services.com>

<LicensingReportProcessResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.acord.org/schema/data/draft/ ... mponents/1" xsi:schemaLocation="http://www.acord.org/schema/data/draft/ ... mponents/1 http://www-mybeta.com/XSD/ACORD/message ... cessResult>
Scott Klement
Site Admin
Posts: 652
Joined: Sun Jul 04, 2021 5:12 am

Re: Multiple structures returned on a SOAP call

Post by Scott Klement »

The data you're receiving is in a format known as "multipart/related". You are trying to treat it as if the data is "application/xml".

To handle this properly, you will not be able to use http_url_post_xml(). You will need to save the result to a file or a string or similar, write a routine that interprets the multipart-related format (HTTPAPI does not have routines for interpreting this format) and that routine would save the XML documents somewhere.

Then you could use XML-INTO, XML-SAX or the XML routines in HTTPAPI to process the XML.

I don't understand the comment about 64k. Are you still using V5R4?! That was the last release of RPG that had a 64k limitation, and it was fully discontinued in 2013 (9 years ago!)
davidb
Posts: 2
Joined: Tue May 31, 2022 3:48 pm

Re: Multiple structures returned on a SOAP call

Post by davidb »

Thanks so much for your response. Yes we're on V7R3. In absence of what I was hoping for, i.e. an httpapi function I may be unaware of, I'm on the right trajectory then. Just a little extra work needed to chop the unwanted xml from the beginning of the receiving file. Thank you.
Post Reply