Wednesday, November 19, 2014

วิธีการเปลี่ยนแปลงค่า Atomic value ของ Element ในตัวแปร Body




ในตัวอย่างจะส่งค่า Inbound มาเป็น <a>111</a> และต้องการเปลี่ยนแปลงค่า 111 เป็นค่าของ Process ID ซึ่งได้จากการ Generate เองหรือได้จากการประยุกค์ใช้กับ Service Callout เพื่อให้ Service อื่น Generate ให้ได้เช่นกัน


Message Flow



































Assign Process ID stage:

Assign =>
<ins:processId xmlns:ins="http://test_processid/ins">
<ins1:returnCode xmlns:ins1="http://test_processid/ins1">0000020141119144</ins1:returnCode>
</ins:processId>



to variable => processid

*** สามารถเป็น Response Document Variable ของ Service Callout ได้

Replace Body variable:

Replace => //proc1:a
In XPath Expression Editor, add User Defined Namespaces
Prefix
URI
proc1 http://test_processid/proc1

in variable => body

with => <proc1:a>{$processid//ins1:returnCode/text()}</proc1:a>
In XPath Expression Editor, add User Defined Namespaces
Prefix
URI
proc1 http://test_processid/proc1
ins1 http://test_processid/ins1

and Replace entire node



Testing

Request document =
<proc1:pos xmlns:proc1="http://test_processid/proc1">
<proc1:a>111</proc1:a>
<proc1:b>222</proc1:b>
<proc1:c>333</proc1:c>
</proc1:pos>

Response document =
<proc1:pos xmlns:proc1="http://test_processid/proc1">
<proc1:a>0000020141119144</proc1:a>
<proc1:b>222</proc1:b>
<proc1:c>333</proc1:c>

</proc1:pos>