0

I have to iterate the DB result.

I used dss to fetch the data from the DB. Now results are coming in a xml format. But my flow is not entering into the iterate mediator. I tried with xpath online tool after removing the xml tag from the output able to form the expression.

Is really required to remove the tag <?xml version='1.0' encoding='UTF-8'?> from the output?

If yes, how to remove this?

I am using WSO2 MI 4.1.0

Below are the sample output from my DB call,

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <Entries xmlns="TotscoDS">
      <statusCodePresent>429
      </statusCodePresent>
      <statusCodePresent>429
      </statusCodePresent>
      <statusCodePresent>429
      </statusCodePresent>
      <statusCodePresent>429
      </statusCodePresent>
      <statusCodePresent>429
      </statusCodePresent>
    </Entries>
  </soapenv:Body>
</soapenv:Envelope>
<payloadFactory media-type="xml">
<format>
<getStates>
<msID>$1</msID>
</getStates>
</format>
<args>
<arg evaluator="xml" expression="$ctx:MI_ID"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="text/xml"/>
<header name="Action" scope="default" value="retrieveStateDetails"/>
<call>
<endpoint key="TotscoEP" />
</call>
<log level="full" />
<iterate expression="//Entries" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<target>
<sequence>
<property expression="//statusCodePresent/text()" name="statusCodePresent" scope="default" type="STRING"/>  
<log level="custom">
<property expression="fn:concat($ctx:HUBMessageID,' : StatusCode = ',$ctx:statusCodePresent)" name="Message"/>
</log>
<filter regex="false" source="boolean(get-property('statusCodePresent'))">
<then>
<log level="custom">
<property expression="fn:concat($ctx:HUBMessageID,' : No Status Code from RCP')" name="Message"/>
</log>

</then>
<else/>                                                                 
</filter>
</sequence>
</target>
</iterate>
[Response in log](https://i.sstatic.net/XIohISqc.png)

1 Answer 1

0

Your namepsace and the Xpath is the issue. Change the Iterate expression like below.

<iterate expression="//dss:statusCodePresent" xmlns:dss="TotscoDS">
  <target>
    <sequence>
.
.
.
    </sequence>
  </target>
</iterate>
Sign up to request clarification or add additional context in comments.

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.