I'm trying to create a xml file, using a compute node. My requirement is to generate the following xml document
<soapenv:Envelope>
<soapenv:Body>
<man:request domain="My-Dom">
<man:b2b-query-metadata>
<man:query>
<man:query-condition evaluation="property-greater-than">
<man:property-name>InputTime</man:property-name>
<man:value>2018-08-10 00:00:00</man:value>
</man:query-condition>
</man:query>
<man:result-constraints>
<man:sort-order>
<man:property-name direction="asc">InputTime</man:property-name>
</man:sort-order>
</man:result-constraints>
</man:b2b-query-metadata>
</man:request>
</soapenv:Body>
</soapenv:Envelope>
Following is the snippet that is used to generate the required xml document.
CREATE COMPUTE MODULE FLOW_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
CALL CreateSOAPReq();
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CreateSOAPReq() BEGIN
DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE man NAMESPACE 'http://www.datapower.com/schemas/management';
SET OutputRoot.HTTPRequestHeader.POST = 'https://my.testbox.com:5550/service/mgmt/3.0';
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'text/xml;charset=UTF-8';
SET OutputRoot.HTTPRequestHeader."Authorization" = 'Basic '||base64Encode(CAST('myuserid:mypassword' as BLOB CCSID InputRoot.Properties.CodedCharSetId));
SET OutputRoot.HTTPRequestHeader.Host = 'my.testbox.com:5550';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.(XMLNSC.Attribute)man:domain = 'My-Dom';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:query.man:"query-condition".evaluation = 'property-greater-than';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:query.man:"query-condition".man:"property-name" = 'InputTime';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:query.man:"query-condition".man:value = '2018-08-10 00:00:00';
--SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:"result-constraints".man:"sort-order".man:"property-name".(XMLNSC.Attribute)man:direction = 'asc';
END;
END MODULE;
Update:
after successfully clearing the hurdle where in i was able to obtain the following xml element: <man:request domain="My-Dom"> using the following statement SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.(XMLNSC.Attribute)man:domain = 'B2B-Dev'; , I am struck at this part: <man:property-name direction="asc">InputTime</man:property-name>
I tried to scan for examples wherein we create outputroot from scratch, however most of the examples deal with parsing through inbound content:
https://www.ibm.com/support/knowledgecenter/en/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac67241_.htm
I understand that we are having attributes, which need to be assigned element value. I'm not sure on how to proceed on this bit. Can someone point me to an example which involves a the SET command in esql.
Any suggestion is welcome.