Hi All,
I have gone through SAP SCN to get help on TraceGains integration but unfortunately there aren't any blog dedicated to it. I am writing this blog to ease the integration of TraceGains with middleware.
Introduction
TraceGains is a cloud-based supplier relationship and quality management platform that helps food and consumer-packaged goods companies deliver on brand promise.
Integration Prerequisites
Tracegains provide a SOAP API for integrating with it. This API consist of various web services and these web services are used for doing the tasks like Login, Logout, Creation of record or Updation of record etc.
Registered Application Name and
Application Key will be used to fetch a new and unique Session ID each time to Login. That session Id needs to be sent each time an interface perform any of the operation given above. We should have all the WSDLs uploaded in ESR as per the need of interface. Along with this, a new SOAP lookup function is required to get the Session ID each time we send the data to TraceGains.
Two SOAP communication channels are required. One for lookup and one for sending data to TraceGains.
TraceGains Session ID LookUp
We need a receiver SOAP communication channel with target given for Login WSDL. This communication channel will add the SOAP envelope for each login call.
Below is the Login request XML structure:
Above request structure can be consumed in a Java code for lookup which is given below.
AppName and
AppKey are the mandatory parameters which will be provided by Tracegains and will be passed as constants to the Java code.
Below is the complete Java Code snippet to fetch the Session ID:
try
{
Channel channel = LookupService.getChannel("Business Component","LookUp_SOAP_R");
SystemAccessor accessor = LookupService.getSystemAccessor(channel);
Payload SOAPpayload = null;
String SOAPxml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
" <Login xmlns=\"https://api">" +
" <appName>"+appName+"</appName>" +
" <appKey>"+appKey+"</appKey>" +
"</Login>" ;
InputStream inputStream =new ByteArrayInputStream(SOAPxml.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
SOAPpayload = accessor.call(payload);
InputStream is = SOAPpayload.getContent();
InputStreamReader isReader = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isReader);
String responseString="";
responseString = reader.readLine();
return ""+responseString;
}
catch(Exception e)
{
trace.addWarning("Error" + e);
return "";
}
Response XML which we get from TraceGains.
Mapping to fetch the Session ID from response XML.
AppName and
AppKey will be passed as constant to the
SessionID function module.
We receive the Session ID within the "
<SessionId>" XML tag shown above in Response XML. To fetch the session ID we can get the first index and last index of "SessionId" tag and extract the string using those indexes.
Below is an example of Material Master Create operation request structure.
Everytime we populate this Create structure, a new session Id will be passed to this structure along with rest of the fields.
Sending Data to TraceGains
TraceGains provide number of SOAP resources like Material Master, Purchase Order or Supplier Items supporting various types of operation. On each SOAP resource we can perform operations like Create,Update,Delete,Get,List etc. We can download the WSDL once SOAP resource and operation is finalized. This WSDL will be used to map between source and target structure.
SOAP target URL and SOAP action we can get from TraceGains portal.
Regards,
Shankul