Hi Vijay,
as I said, there’s no out-of-the-box policy that does what you want. Of course you could do it with an XSLT policy, but not many people like to write and maintain XSLT code.
But it’s pretty easy to create custom policies in Apigee Edge. So I wrote one that does this.
It’s available on github.
I published the Java source code, but you actually don’t need to look at the Java or even compile it. You just need the jar file. What you’ll do is configure a Java callout that references the jar, and sets the appropriate properties - things like the xpath of the node you want to replace, and the xml namespaces required by the xpath, and so on.
I have also published an example apiproxy bundle that does just what you want. It’s on the same github repo. It shows exactly how to configure it to do what you described.
For example, here’s the configuration for the policy for the scenario above:
<JavaCallout name='Java-AddXmlNode-2'>
<Properties>
<Property name='xmlns:soap'>http://schemas.xmlsoap.org/soap/envelope/</Property>
<Property name='xmlns:act'>http://yyyy.com</Property>
<Property name='source'>request.content</Property>
<Property name='new-node-type'>text</Property>
<Property name='new-node-text'>{request.queryparam.texttoinsert}</Property>
<Property name='xpath'>/soap:Envelope/soap:Body/act:test/abc/act:demo/text()</Property>
<Property name='action'>replace</Property>
</Properties>
<ClassName>com.dinochiesa.edgecallouts.AddXmlNode</ClassName>
<ResourceURL>java://edge-custom-add-xml-node.jar</ResourceURL>
</JavaCallout>
All of that should mostly make sense.
And you can even try it out. I have the bundle deployed and running, so you can use this to test it:
curl -i -X POST -H content-type:text/xml \
'http://deecee-test.apigee.net/add-xml-node/t2?texttoinsert=decrypted-text-here' \
-d '
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<act:test xmlns:act="http://yyyy.com">
<abc>
<act:demo>fokyCS2jrkE5s+bC25L1Aax5sK//FkYA1msxIyW7prOun0VwoSET73UXKyKJ7nmd3OwHq/08GXIpwlq3QBJuG7a4Xgm4Vk</act:demo>
</abc>
</act:test>
</soapenv:Body>
</soapenv:Envelope>
'
The result should show you the text of the act:demo element replaced with the text supplied in the query param. Like so:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<act:test xmlns:act="http://yyyy.com">
<abc>
<act:demo>decrypted-text-here</act:demo>
</abc>
</act:test>
</soapenv:Body>
</soapenv:Envelope>
This should get you what you want.
Let me know if you have questions or problems.