XML Response to large?

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
erinklanderman
Posts: 4
Joined: Mon Mar 20, 2023 2:54 pm

XML Response to large?

Post by erinklanderman »

Hello,
I created a program based on example16. I am connecting to a SOAP service, sending XML. I am recieving back an XML response and trying to use XML-INTO and populate into a ds to get the values that I require.

Here is my ds:
dcl-ds search_status qualified;
result_guid char(50);
company_id char(25);
dts_search_date char(25);
dts_status char(10);
dts_match char(1);
dts_last_validated_date char(25);
dts_override char(1);
dts_override_date char(25);
num_hits char(5);
end-ds;

I build the XML and do the following:
monitor;
PostResult = http_string( 'POST': url: PostData: 'text/xml');
on-error;
ErrorMsg=http_error();
PostResult='<Result>Error</Result>';
endmon;

I then do:
monitor;
//Parse output
xml-into search_status %xml(PostResult: 'case=any ns=remove +
path=Envelope/Body/DPSIntegratedSearchResponse+
/DPSIntegratedSearchResult/dts_search_results+
/entry/search_status');
on-error;
error = 'Unable to parse XML data';
return;
*inlr = *on;
endmon;

It fails every time. When I look at the data in debug mode I am not getting any data that I care about really. It seems like there is a lot of spaces before the data I am looking for. I can't seem to attach the log file here, but I have it if needed.
Any assistance is appreciated.
Erin
erinklanderman
Posts: 4
Joined: Mon Mar 20, 2023 2:54 pm

Re: XML Response to large?

Post by erinklanderman »

Here is what I get back - Part 1 because it is over 60000 characters so i can't post the whole thing. This first part is all data I don't care about:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap ... chResponse xmlns="http://integrationpoint.com/"><DPSInteg ... ch_results xmlns=""><search_request><![CDATA[<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:int="http://integrationpoint.com/"><soap:Hea ... me>Company Name</int:name><int:address>Addr Line 1</int:address><int:city>City</int:city><int:countryCode>US</int:countryCode><int:countryStateCode>?</int:countryStateCode><int:postalCode>?</int:postalCode><int:dtsSearchFlag>Y</int:dtsSearchFlag><int:dtsLastValidatedDate>?</int:dtsLastValidatedDate><int:dtsOverride>?</int:dtsOverride><int:dtsOverrideDate>?</int:dtsOverrideDate><int:SearchRefNum>C3_1_1_ 456467_1</int:SearchRefNum><int:CompanySync>Y</int:CompanySync><int:EntityType>ORGANIZATION</int:EntityType></int:DPSIntegratedSearch></soap:Body></soap:Envelope>
erinklanderman
Posts: 4
Joined: Mon Mar 20, 2023 2:54 pm

Re: XML Response to large?

Post by erinklanderman »

This is the part 2 of what I get back.....after hundreds of spaces. I only care about the data past the search_request.

]]></search_request><entry><search_status><result_guid>930f5856-1ffc-4960-9c01-f4fb65c8889a</result_guid><company_id /><dts_search_date>3/20/2023 10:22:19 AM</dts_search_date><dts_status>Clear</dts_status><dts_match>N</dts_match><dts_last_validated_date>3/20/2023 10:22:19 AM</dts_last_validated_date><dts_override>N</dts_override><dts_override_date>1/1/1900</dts_override_date><num_hits>0</num_hits></search_status><summary_results /></entry></dts_search_results></DPSIntegratedSearchResult></DPSIntegratedSearchResponse></soap:Body></soap:Envelope>
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: XML Response to large?

Post by jonboy49 »

This is an uber-simplified version of your code using a subset of the XML you supplied in a file. It works.

Code: Select all

**free
 
dcl-ds search_status qualified;
   result_guid char(50);
   company_id char(25);
   dts_search_date char(25);
   dts_status char(10);
   dts_match char(1);
   dts_last_validated_date char(25);
   dts_override char(1);
   dts_override_date char(25);
   num_hits char(5);
end-ds;
 
xml-into search_status %xml('/home/paris/xmlstuff/play.xml'
: 'case=any ns=remove doc=file +
path=Envelope/Body/DPSIntegratedSearchResponse+
/DPSIntegratedSearchResult/dts_search_results+
/entry/search_status');
 
*inlr = *on;
Here's the XML subset I used.

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<Envelope>
  <Body>
    <DPSIntegratedSearchResponse>
      <DPSIntegratedSearchResult>
        <dts_search_results>
          <entry>
            <search_status>
              <result_guid>930f5856-1ffc-4960-9c01-f4fb65c8889a</result_guid>
              <company_id />
              <dts_search_date>3/20/2023 10:22:19 AM</dts_search_date>
              <dts_status>Clear</dts_status>
              <dts_match>N</dts_match>
              <dts_last_validated_date>3/20/2023 10:22:19 AM</dts_last_validated_date>
              <dts_override>N</dts_override>
              <dts_override_date>1/1/1900</dts_override_date>
              <num_hits>0</num_hits>
            </search_status>
            <summary_results />
          </entry>
        </dts_search_results>
      </DPSIntegratedSearchResult>
    </DPSIntegratedSearchResponse>
  </Body>
</Envelope>
Since you didn't supply all of you data definitions etc. all I can suggest is that you perhaps comment out the monitor block so that you can more easily see the real error you are getting. There doesn't appear to be anything fundamentally wrong with what you have done.
Post Reply