PARSE XML (WSDL) file example program

Recently I’ve got a question from a customer related to the PARSE statement introduced with Natural 6. The following simle program parses an XML file - here a WSDL file and displays the xml-path etc.
The code and the WSDL file is included below however you may parse other XML files…
I hope you find this example program useful. 8)

With best regards,
Michael Muenster


/* example program PARSE-P
/* PARSE an arbitrary XML file
/* the program requires SYSWEB as steplib
/* the ‘qotd.wsdl’ file must be placed in the RES directory
/* of the library where this program ist stored.
/*
DEFINE DATA LOCAL
01 XML-DATA (A) DYNAMIC
01 #XML-PATH (A) DYNAMIC
01 #XML-NAME (A) DYNAMIC
01 #XML-VALUE (A) DYNAMIC
END-DEFINE

FORMAT LS=120 PS=40
PERFORM W3READ-RESOURCE ’ ’ ‘qotd.wsdl’ XML-DATA

PARSE XML XML-DATA INTO PATH #XML-PATH
NAME #XML-NAME
VALUE #XML-VALUE
DISPLAY #XML-PATH (AL=60) #XML-NAME (AL=15) #XML-VALUE (AL=30) *PARSE-TYPE

END-PARSE
END


<?xml version="1.0"?>
<message name="getQuoteRequest" />

<message name="getQuoteResponse">
	<part name="return" type="xsd:string"/>
</message>


<portType name="qotdPortType">
	<operation name="getQuote">
		<input name="getQuote" message="tns:getQuoteRequest"/>
		<output name="getQuoteResponse" message="tns:getQuoteResponse"/>
	</operation>
</portType>
<binding name="qotdBinding" type="tns:qotdPortType">
	<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
	<operation name="getQuote">
		<soap:operation soapAction="urn:xmethods-qotd#getQuote"/>
		<input>
			<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:xmethods-qotd"/>
		</input>
		<output>
			<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:xmethods-qotd"/>
		</output>
	</operation>

</binding>
<service name="qotd">
	<documentation>
     Get a Quote of the Day
  </documentation>
	<port name="qotdPort" binding="tns:qotdBinding">
		<soap:address location="http://webservices.codingtheweb.com/bin/qotd"/>
	</port>
</service>
---------------------------------------------

Three things missing:
1st save the xml with name “qotd.wsdl” and then drag this file to your Natural Library you are running this program from.
2nd A steplib to library SYSWEB is necessary, otherwise W3READ-RESOURCE cannot not found.
3rd according the documentation of W3READ-RESOURCE (can be found at the Web Technology → Natural Web Interface → Natural Web Online Documentation → Template / XSLT Processing → W3READ-RESOURCE)
a additional #response parameter should be used to see possible errors.