Wednesday, February 4, 2015

Rename the Namespace:

Sometimes we need to rename the namespace as the target xml doesn't have the same namespace as source xml. We have done this lots of time in BPEL through XSLT, lets see in the OSB using built in Activity here.

There is the Rename Activity which can be used to the same as below :

My request XML :

<say:NewOperation xmlns:say="http://www.example.org/sayHello/">
<in1>string</in1>
<in2>string</in2>
<in3>string</in3>
</say:NewOperation>

Here I came across the requirement where has the namespace as http://x.y.com/z in target XML

so I have tried the simple approach of rename activity where
select the element in the Xpath field.
put body in the "In Variable" as the request payload comes under body variable.
leave the Localname as blank
provide the namespace value in the namespace field


Request payload:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
</soap:Header>
<soapenv:Body>
<say:NewOperation xmlns:say="http://www.example.org/sayHello/">
<in1>string</in1>
<in2>string</in2>
<in3>string</in3>
</say:NewOperation>
</soapenv:Body>
</soapenv:Envelope>

Response payload:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
</soap:Header>
<soapenv:Body>
<say:NewOperation xmlns:say="http://www.example.org/sayHello/">
<in1>string</in1>
<z:in2 xmlns:z="http://x.y.com/z">string</z:in2>
<in3>string</in3>
</say:NewOperation>
</soapenv:Body>
</soapenv:Envelope>