on 02-20-2023 11:17 PM
Hi All,
I tried to extract the Body data from the XML payload, but couldn't succeed so I blogged and couldn’t found the one which suits my requirement. Hence I am writing this blog to make the script/Content Modifier based on the requirement.
Requirement
I need to fetch the data which is in the Body, I declared the xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" in main and tried to fetch the data using content modifier. But the body is coming as blank after the Content Modifier step execution by giving the path as //s:Envelope/s:Body/.
I tried using the Groovy script using the removal statement by below code, but its failing.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
def removal=message.getBody(java.lang.String) as String;
removal=removal.replace(/s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/,””);
message.setBody(removal);
return message;
}
Payload.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" s:mustUnderstand="1">http://sap.com/xi/WebService/soap1.1</Action>
</s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<_BAPI_PO_GETDETAILS xmlns="urn:sap-com:document:sap:rfc:functions">
<PO xmlns=""/>
</_BAPI_PO_GETDETAILS>
</s:Body>
</s:Envelope>
Can you all please help me on this using the content modifier where i am wrong. I have highlighted in bold which i required in payload.
Thank you in advance.
Regards,
Meer Hyder Ali
<br>
Hello Hyder Ali,
you can declare a content modifier and copy the body into a parameter, that you set as the body of the message.
If you use local-name() functionality in XPath you do not need to know the namespace of your selected node.
IFlow:
Parameters:
Name: ExtractedMessage
SourceType: XPath
SourceValue: //*[local-name()='_BAPI_PO_GETDETAILS']
DataType: org.w3c.dom.NodeList
Body:
Expression: ${property.ExtractedMessage}
input:
output:
If the answer helps you, please consider to accept it.
Best Regards
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert,
Thanks for your inputs, without hardcode is there any way to the data, as we have different payloads with same format, only the below content gets changed. Else I need to create multiple iflows.
<_BAPI_PO_GETDETAILS xmlns="urn:sap-com:document:sap:rfc:functions">
<PO xmlns=""/>
</_BAPI_PO_GETDETAILS>
Regards,
Meer Hyder Ali
Hi Hyder,
as long as you now, that you want the third descandand of the root node, you can change the XPath to "/*/*/*".
First would be the Envelope Element, second the Body Element, and the third Element is your selected node regardless the name or namespace of it.
Best Regards
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Morten,
Thanks for your inputs, I need the data only to be received as below. Also we have different payloads with same format only the below content gets changed. Hence I need to capture the data. If there is <Body> available then RFC ADAPTER is through an error.
<_BAPI_PO_GETDETAILS xmlns="urn:sap-com:document:sap:rfc:functions">
<PO xmlns=""/>
</_BAPI_PO_GETDETAILS>
Regards,
Meer Hyder Ali
Hi meerhyderali
No, the Filter step is the only step needed.
As I said, I've already tested the solution. If it's not working for you, then the payload is different from what you showed.
Regards,
Morten
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.