Assuming we are getting the following request to the WSO2 ESB.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"establish": [{ | |
"customerId": "6666634324", | |
"serviceTransactionID": "TOA157934", | |
"displayText": "Transfer from HNB to NDB", | |
"milestonesDef": { | |
"Transfer-Started": "You have started the transfer", | |
"Transfer-Initiated": "You have submitted the transfer", | |
"Transfer-Processing": "Processing your request", | |
"Complete": "Transaction Complete" | |
} | |
}] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dat:EstablishMilestone xmlns:dat="http://ws.wso2.org/dataservice"> | |
<dat:customer_ID>6666634324</dat:customer_ID> | |
<dat:serviceTransaction_ID>157934</dat:serviceTransaction_ID> | |
<dat:milestone_def>{"Transfer-Initiated":"You have submitted the transfer","Transfer-Processing":"Processing your request","Transfer-Started":"You have started the transfer with Vanguard","Complete":"Transaction Complete"}</dat:milestone_def> | |
</dat:EstablishMilestone> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<sequence name="sample_sequence" onError="fault_sequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> | |
<!-- store required JSON content to a variable --> | |
<property name="JSONPayload" expression="json-eval($.establish[0].milestonesDef)" /> | |
<log level="full"> | |
<property name="====JSONPayload====" expression="$ctx:JSONPayload"></property> | |
</log> | |
<!-- | |
{ | |
"Transfer-Initiated":"You have submited the transfer", | |
"Fidelity-Processing":"Fidelity processed your request", | |
"Transfer-Started":"You have started the transfer with Vanguard", | |
"Custodian-Processing":"Vanguard is processing your request", | |
"Complete":"Transaction Complete" | |
} | |
--> | |
<!-- construct the xml message with JSON content--> | |
<payloadFactory media-type="xml"> | |
<format> | |
<dat:EstablishMilestone xmlns:dat="http://ws.wso2.org/dataservice"> | |
<dat:customer_ID>$2</dat:customer_ID> | |
<dat:serviceTransaction_ID>$1</dat:serviceTransaction_ID> | |
<dat:milestone_def>$3</dat:milestone_def> | |
</dat:EstablishMilestone> | |
</format> | |
<args> | |
<arg expression="//jsonObject/establish/serviceTransactionID" /> | |
<arg expression="//jsonObject/establish/customerId" /> | |
<arg expression="$ctx:JSONPayload" /> | |
</args> | |
</payloadFactory> | |
<!-- convert message to xml ---> | |
<property name="messageType" value="application/xml" scope="axis2" /> | |
<send> | |
<endpoint key="backend_endpoint"/> | |
</send> | |
</sequence> |
Comments