on 10-14-2015 7:40 PM
Dear Scn users,
I need an UDF to get mulitple values(Not single Value) from Soap Call By sending 2 inputs.Actually its a BRM call.
Can anyone help me with the code or any links?
Regards
Raghu Ram
Issue solved.change the UDF logic.
Thanks Eng and everyone for the help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Everyone,
Just a small confirmation..
The code seems to be fine(checked in other PO system). problem is BRM is not getting called. We checked in logs and traces.
Will it be because of PI version and SP levels?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you use UDF of type All Values of a Context and output You will be giving ordernumber and quantity.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can refer to the code from the link Raghu posted. Instead of using a Single Values UDF, switch it to one of the other two. Add two Result output to enable multiple output. It does not matter if you just have one value in each queue.
To output the values, you can use approval.addValue("somevalue") or infy.addValue("othervalue")
Yes, if you plan to use XPath expression in your UDF logic, then put the evaluation of the XPath there.
Note that the link by Raghu uses DOM nodes to get to the required element, while the one by Inaki uses plain String searching. How you want to parse and extract the response is entirely up to you.
Hello Eng,
Below is the code
AbstractTrace trace = container.getTrace();
String Approval = "";
try {
trace.addInfo("Before assigning the channel");
Channel channel = LookupService.getChannel("BC_BRM","SoapReceiver_BRM_POC2");
SystemAccessor accessor = LookupService.getSystemAccessor(channel);
String SOAPxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<ns1:Request-demo.sap.com-poc-nwbrm2-POC-BRM-PORule-New-POC-BRM-PORule-New xmlns:ns1=\"http://www.sap.com\"><ns2:mt_BRM xmlns:ns2=\"Peter:test\">"+
"<OrderNumber>"+OrderNumber+"</OrderNumber>"+
"<Quantity>"+Quantity+"</Quantity>"+
"<Approval></Approval>"+
"<OrderInfo></OrderInfo>"+
"</ns2:mt_BRM>"+
"</ns1:Request-demo.sap.com-poc-nwbrm2-POC-BRM-PORule-New-POC-BRM-PORule-New>";
InputStream inputStream = new ByteArrayInputStream(SOAPxml.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
Payload SOAPOutPayload = null;
trace.addInfo("Before calling the method");
SOAPOutPayload = accessor.call(payload);
accessor.close();
trace.addInfo("After calling the method");
InputStream inp = SOAPOutPayload.getContent();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(inp);
Node root = document.getFirstChild(); // gets the root element
NodeList record = root.getChildNodes();
NodeList list = document.getElementsByTagName("Response-demo.sap.com-poc-nwbrm2-POC-BRM-PORule-New-POC-BRM-PORule-New");
Node node = list.item(0);
if (node != null) {
node = node.getFirstChild();
if (node != null) {
Approval = node.getNodeValue();
//trace.addInfo(Approval);
}
}
}
catch (Exception e) {
trace.addWarning("Error" + e);
}
return Approval;
Can you please help if something is wrong here and how to add second value.I am a bit confused
Raghu
Since you want to get the value from the <Approval> field, you need to change the input value to the getElementsByTagName method to pass in the field instead of the root element.
NodeList list = document.getElementsByTagName("Approval");
After you have retrieved content into your declared Approval variable, replace the return statement with the following. Note that approval (lower case) is declared as the signature of type ResultList and Approval (upper case) if the temporary String you declared.
approval.addValue(Approval);
I'd assume you are familiar with returning values for Context/Queue UDFs since you wrote the following blog.
The only difference is that instead of having a single output signature named result, you have two output signature named approval and infy.
So for OrderInfo, you just repeat the logic, retrieve it from element OrderInfo and use the second output parameter to output it.
Rgds
Eng Swee
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.