cancel
Showing results for 
Search instead for 
Did you mean: 

Soap Lookup

former_member186851
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Issue solved.change the UDF logic.

Thanks Eng and everyone for the help.

Answers (4)

Answers (4)

former_member186851
Active Contributor
0 Kudos

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?

iaki_vila
Active Contributor
0 Kudos

HI Raghuraman,

have you check this document ?, you can check the java code for BRMLookup on the step 3.

Have you tried with another tool that you really get a set of element of that SOAP request?

Regards.

former_member186851
Active Contributor
0 Kudos

Hello Inaki,

Let me try the code.

What is the other tool? And I don't want to use NWBPM.

former_member405782
Discoverer
0 Kudos

you use UDF of type All Values of a Context and output You will be giving ordernumber and quantity.


RaghuVamseedhar
Active Contributor
0 Kudos

Raghu,

You can use UDF 1 in this blog and get XML response. After successful testing, enhance the UDF using DOM or SAX to retrieve required fields.

FYI you can also check

former_member186851
Active Contributor
0 Kudos

Hello Raghu,

Thanks for the response.

But my requirement is a bit different.

I have 2 inputs and 2 outputs

Like Ordernumber and quantity will be the inputs and approval and reason will be the outputs

Is there way to get two outputs using UDF?

engswee
Active Contributor
0 Kudos

If you use UDF of type All Values of a Context or All Values of Queue, then you can set more than 1 output.

former_member186851
Active Contributor
0 Kudos

Hello Eng,

But I will just have one value in the Queue for each output.

This is my structute

mt_BRM

<OrderNumber>

<Quantity>

<Approval>

<Infy>

I will be giving ordernumber and quantity as input

Output from webservice will be approval and infy

Can you please help me with the code.

engswee
Active Contributor
0 Kudos

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")

former_member186851
Active Contributor
0 Kudos

Eng,

So in the place of other value and some value I should replace with Xpath of the outputs right?

engswee
Active Contributor
0 Kudos

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.

former_member186851
Active Contributor
0 Kudos

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

engswee
Active Contributor
0 Kudos

Please provide content of your XML response payload.

former_member186851
Active Contributor
0 Kudos

Hello Eng,

Request and reponse looks like below

engswee
Active Contributor
0 Kudos

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