Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
rodrigoalejandro_pertierr
Active Contributor

I saw many thread about how to create a SOAP Lookup in PI since the standard function up today involves only the RFC and JDBC Lookup

until this point become standard, the only way to implement it is manually,

below you will find a detailed executed scenario to show you how to do it.

you can also refer to this similar blog by Bravesh: Web Service Call from UDF

In this case i will use a simple structure that send two parameter to a service and it returns the sum of them.

so a Message Mapping has to be created.


The same structure is used as source and target to make this scenario more simple, as you can see a UDF was created (SOAP_LookUp) to invoke a service to summarize both values.

Libraries used:

import java.io.*;

import java.util.Map;

import com.sap.aii.mapping.lookup.*;

import javax.xml.parsers.*;

import javax.xml.transform.*;

import javax.xml.transform.dom.DOMSource;

import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.*;

import org.xml.sax.*

Function CODE

*********************************************************************************************************************

AbstractTrace trace = container.getTrace();

String suma = "";

try {

//instance the channel to invoke the service.

Channel channel = LookupService.getChannel("CCR_SOAP_LookUP","cc_SOAP_Lookup_receiver");

SystemAccessor accessor = LookupService.getSystemAccessor(channel);

// The Request message in XML. THIS IS THE LOOKUP SERVICE

String SOAPxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:SendDataToStorage xmlns:ns0=\"http://Test.Service.SchemaIn\"> <Valor1>"

+ var1

+ "</Valor1><Valor2>"

+ var2

+ "</Valor2></ns0:SendDataToStorage>";

InputStream inputStream =new ByteArrayInputStream(SOAPxml.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload SOAPOutPayload = null;

//The response will be a Payload. Parse this to get the response field out.

SOAPOutPayload = accessor.call(payload);

/* Parse the SOAPPayload to get the SOAP Response back.  

The conversion rate is available under the Field Name ConversionRateResult */ 

InputStream inp = SOAPOutPayload.getContent();  

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  

/* Create DOM structure from input XML */  

DocumentBuilder builder = factory.newDocumentBuilder();  

Document document = builder.parse(inp); 

  /* ConversionRate is available in the TAG ConversionRateResult in the Response XML */

NodeList list = document.getElementsByTagName("Response");

Node node = list.item(0);   

if (node != null) {

node = node.getFirstChild();        

if (node != null) {  

suma = node.getNodeValue();        

}  

}

} catch (Exception e) { 

trace.addWarning("Error" + e);  }

  1. a.     trace.addInfo("Service XXX success executed");

return suma;


*****************************************************************************

Once all the configuration is made in the ESR and ID we can execute the scenario, in my case i will use the soft HTTP Client for SAP Process integration that could be downloaded from: http://sappihttpclient.codeplex.com

Don’t get confuse with the QoS, even if the Lookup is sync, the QoS of our interface is Exactly Once.

Message Monitor

to check whether the interface process success is let go to SXI_MONITOR to see what happened

so as far we can see the scenario process success, so, let’s check if the data process success in the adapter engine., so let’s go to Runtime Workbench-->communication component--> adapter engine-->Communication channel monitoring.

Select the proper channel associated to our backend system press the USE FILTER button.

if every looks like the picture, click on "Message Processing completed ..." to get the payload of message

Once the popup comes up, go to Message Content tab and select the option "PAYLOAD........" from the drop-down-list. a message similar to the below picture should be displayed.

and that it, hope you can get a more clear idea about how to configure such scenarios using SOAP Lookup

3 Comments
Labels in this area