I wish to set an array in WSO2ESB in my scenario.
I am sending two parameters to database and getting number of rows but I need only one row.
My configuration is
<target>
<sequence>
<property name="partybranchid"
expression="get-property('partybranchid')"
scope="default"
type="STRING"/>
<payloadFactory>
<format>
<p:Select_MailDetails_Op xmlns:p="http://ws.wso2.org/dataservice">
<xs:assetid xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:assetid>
<xs:partybranchid xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:partybranchid>
</p:Select_MailDetails_Op>
</format>
<args>
<arg expression="get-property('assetid')"/>
<arg expression="get-property('partybranchid')"/>
</args>
</payloadFactory>
<log level="full"/>
<send receive="Mail_Seq">
<endpoint>
<address uri="http://localhost:9764/services/massetparametersetdetail_DataService/"
format="soap11"/>
</endpoint>
</send>
</sequence>
</target>
and I am receiving data in this sequence:
<log><property xmlns:v="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd"
name="primarymail" action="set"
expression="//v:primarymail/text()"
scope="default"
type="STRING"/></log>
<iterate xmlns:v="http://ws.wso2.org/dataservice"
xmlns:ns="http://org.apache.synapse/xsd"
id="Mail"
expression="//v:Datalist">
<target>
<sequence>
<property xmlns:v="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd"
name="primarymail"
expression="//v:primarymail/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="assetname"
expression="//assetname/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="assetcode"
expression="//assetcode/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="activityname"
expression="//activityname/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="username"
expression="//username/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="parametername"
expression="//parametername/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="uomcode"
expression="//uomcode/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="tododetails"
expression="fn:concat('AssetName:',get-property('assetname'),',','AssetCode:',get-property('assetcode'),',','ActivityName:',get-property('activityname'),',','UserName:',get-property('username'),',','ParameterName:',get-property('parametername'),',','UomCode:',get-property('uomcode'))"
scope="default"
type="STRING"/>
<log><property xmlns:v="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd"
name="primarymail" action="set"
expression="//v:primarymail/text()"
scope="default"
type="STRING"/></log>
</sequence>
</target>
</iterate>
</sequence>
and I am getting response like below but I want to send a mail only once.
Here my mailid is repeating. How can I take out this mail id?
response, primarymail = [email protected]@[email protected]@[email protected]@[email protected]@[email protected]@myunisoft.com
How can I take single mail for this?
Your webservice response is a SOAP message and What you get in to any mediator in ESB, is that particular incoming message. You cannot directly have an array of values.
- One option is to use a class mediator and extract your desired value/s and set that value to a property in message context and use it.
- if the response payload can be altered in your scenario, return the response with a known delimiter and use xpath String operations to get your value.