0

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.

8
  • This OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.(XMLNSC.Attribute)domain = 'My-Dom'; should work fine. How are you checking the output? Commented Sep 5, 2018 at 8:25
  • Hi Attila, For the POC, I've setup MQ->ComputeNode->SOAPRequestNode->MQ.. I'm using flow exerciser as well as debug option.... Commented Sep 5, 2018 at 8:57
  • The debugger doesn't always show the attributes clearly, so I'd suggest you look at the output MQ message directly, with RFHUTIL or any other MQ reader. Commented Sep 7, 2018 at 6:21
  • Hi Attila, I've placed a MQ Node after the compute node and have placed the output extracted using RFHUtil. Commented Sep 7, 2018 at 8:43
  • I'm confused, in none of your code examples you have (XMLNSC.Attribute) for the domain element. Which code produced this MQ output? Why do you have (XMLNSC.NamespaceDecl) for domain? In your desired output domain is not a namespace declaration. Commented Sep 9, 2018 at 17:05

3 Answers 3

0

That's not an ordinary XML attribute - it is a namespace declaration. You need to declare a namespace constant, and then use it in your ESQL as described here:

https://www.ibm.com/support/knowledgecenter/en/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ac67194_.htm

Sign up to request clarification or add additional context in comments.

2 Comments

I tried the link you had shared, and tried this: ` DECLARE sp NAMESPACE 'B2B-Dev'; SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.sp:request.(XMLNSC.NamespaceDecl)"domain" = sp;... This time output was <NS2:request/> <NS3:request> <NS3:b2b-query-metadata> `... Incorrect understanding of the example they gave :(
I treid the example for non-empty prefix.
0

Heres a breakdown for what I've faced so far.

  1. relied solely on Flow exerciser, should have checked the queue content once in a while.
  2. altering OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.(XMLNSC.Attribute)man:domain = 'My-Dom';, resolved and I'm getting outcome as desired when a MQ Output node is placed in front of the Compute node.

Thanks to @Attila Repasi for pointing the flaws, in my esql code. :)

Comments

0

Try flipping the assignments.

Assuming below is the XML

<NS1:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/">
   <NS1:Header/>
   <NS1:Body>
      <NS2:request domain="default" xmlns:NS2="http://www.datapower.com/schemas/management">
         <NS2:set-file name="local:///Phase1/tullu">UGlzdGFzaW5naA==</NS2:set-file>
      </NS2:request>
   </NS1:Body>
</NS1:Envelope>

Below is the ESQL

SET OutputRoot.XMLNSC.ns21:Envelope.ns21:Body.ns39:request.(XMLNSC.Attribute)domain = datapowerDomain;
SET OutputRoot.XMLNSC.ns21:Envelope.ns21:Body.ns39:request.ns39:"set-file"=InputRoot.XMLNSC.ns:createFileRequest.directoryDetails.fileContentsInBase64;     
SET OutputRoot.XMLNSC.ns21:Envelope.ns21:Body.ns39:request.ns39:"set-file".(XMLNSC.Attribute)name=targetFQFileName;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.