cancel
Showing results for 
Search instead for 
Did you mean: 

SFDC Integration with SAP PI error

rasjoshi
Active Contributor
0 Kudos

Hi,

I am trying to integrate ECC with SFDC, I have created SOAP LOOKUP UDF to get the session ID, while testing interface using SOAP UI I am getting below error -

<!--see the documentation--> <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Body> <SOAP:Fault> <faultcode>SOAP:Server</faultcode> <faultstring>Server Error</faultstring> <detail> <s:SystemError xmlns:s="http://sap.com/xi/WebService/xi2.0"> <context>XIAdapter</context> <code>ADAPTER.JAVA_EXCEPTION</code> <text>See log trace with id: n/a</text> </s:SystemError> </detail> </SOAP:Fault> </SOAP:Body> </SOAP:Envelope>

After checking CC created for SOAP LOOKUP, I observed call going for login but while getting response it is giving error -

08/02/2017 10:26:48 America/New_York9e40a760-778e-11e7-a9ec-000000827896error in response08/02/2017 10:26:48 America/New_York9e40a760-778e-11e7-a9ec-000000827896call completed08/02/2017 10:26:48 America/New_York9e40a760-778e-11e7-a9ec-000000827896Request Entering

Accepted Solutions (0)

Answers (5)

Answers (5)

rasjoshi
Active Contributor
0 Kudos

Hi Manoj K,

I am able to get sessionID... While triggering message from SOAPUI I am getting RESPONSE error message -

SOAP: Error occurred: com.sap.engine.interfaces.messaging.api.exception.MessagingException: SOAP: Response message contains an errorXIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 500 Server Error

I downloaded payload from RWB and again tested the same using SOAPUI, here I am getting response back.

Any idea what might be causing issue now?

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

Rashmi,

if i understand your problem you are able to get session id from SOAP UI but not from PI system?If yes then the best way to check is the trace file i.e the final payload with http headers from PI with SOAP UI RAW data and see if you can see any difference between then.

You need to enable Trace in your Soap Lookup channel. and then compare that trace file request and response with soap UI.

For HTTP 500 there is no fixed solution this error is thrown by server or PI which is not able to interpret the server's response .500 is the error which is thrown when there is no descriptive for any other error like (4**) so you need to cross check the payload,http headers , content type etc..

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Hi Manoj,

I am able to get sessionID from both SOAP UI and PI, after this I am triggering query() method for ACCOUNT in SFDC... While triggering this interface I am getting HTTP 500 error in response -

ErrorSOAP: Response message contains an errorXIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 500 Server Error
InformationSOAP: Continuing to response message 7f8ebe60-80c2-11e7-a516-000000827896
ErrorMP: exception caught with cause com.sap.engine.interfaces.messaging.api.exception.MessagingException: SOAP: Response message contains an errorXIAdapter/HTTP/ADAPTER.HTTP_EXCEPTION - HTTP 500 Server Error

Am I missing something in response message... How can I check response payload....

manoj_khavatkopp
Active Contributor
0 Kudos

Hi Rashmi,

Enable the trace in the channel whichever is having this error , The trace will come in handy so to understand what is going on with request an response payload.

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Hi Manoj,

I am getting missing header error for response message, does it mean I need to write java program again to handle response message -

CLIENT: 17030 RESPONSE: - 287 bytes:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>SOAPAction HTTP header missing</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>

Below is my request message -

CLIENT: 17030 REQUEST: - 519 bytes:

<?xml version="1.0" encoding="UTF-8" ?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com"><soapenv:Header><urn:SessionHeader><urn:sessionId>00D7F000001ZuF3!ARgAQI5jdn5kYoEaHUGH7tYlF7ebGhyguPdH4bc6RexSHP.5RnJh4o1gHa6q1yCZyJr0ShQcFsUEfBuv4E9IGTrE_EtYd5g7</urn:sessionId></urn:SessionHeader></soapenv:Header><soapenv:Body><urn:query><urn:queryString>Select Name, Phone, OwnerId from Account</urn:queryString></urn:query></soapenv:Body></soapenv:Envelope>

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

This is currently what is happening in your scenario :

1.Initial call is made to SFDC for getting SESSION ID and URL which is done by SOAP Look up channel which has URL :https://salesforce.com/services/SOAP/c/40.0 and soap action as :login.

2.Now once you get the Session ID and URL you populating session ID in one of the target field and you are using the URL for SOAP receiver channel via Dynamic UDF . But note here you are setting only Dynamic URL you have not mentioned and SOAP action so the error :

Client SOAPAction HTTP header missing

So i believe the SOAP action is always static for this call only URL is dynamic , if yes then check which SOAP Action is used in SOAP UI and mention the same in your reciever channel.

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Hi Manoj,

Finally able to get the response message but failing with below log -

Transmitting the message using connection SOAP_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error encountered while executing mapping: com.sap.aii.af.service.mapping.MappingException: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_SFDC_ACCOUNT_RESP_; Details: com.sap.aii.mappingtool.tf7.IllegalInstanceException; Cannot create target element /ns0:queryResponse. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD

BR,

Rashmi

rasjoshi
Active Contributor
0 Kudos

So basically I am getting HEADER in response message which I need to handle in PI now... Any idea how can I delete this header message and select only BODY part?

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

The error is because of the mandatory filed missing in your receiver mapping , can you please check what is the response you are getting from SFDC and what is the response it is expecting in your receiver mapping.

What actually you mean by below sentence ?

So basically I am getting HEADER in response message which I need to handle in PI now... Any idea how can I delete this header message and select only BODY part?

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

So this is what is coming from SFDC -

<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:sf="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:enterprise.soap.sforce.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <LimitInfoHeader> <limitInfo> <current>22</current> <limit>15000</limit> <type>API REQUESTS</type> </limitInfo> </LimitInfoHeader> </soapenv:Header> <soapenv:Body> <queryResponse> <result> <done>true</done> <queryLocator xsi:nil="true"/> <records xsi:type="sf:Account">

And my response map in SAP PI is like this -

<?xml version="1.0" encoding="UTF-8"?> <ns0:queryResponse xmlns:ns0="urn:enterprise.soap.sforce.com"> <ns0:result> <ns0:done/> <ns0:queryLocator/> <ns0:records> <ns1:fieldsToNull xmlns:ns1="urn:sobject.enterprise.soap.sforce.com"/>

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

Rashmi,

Try to uncheck "Do Not use soap Envelope" in ur receiver channel if you are still facing issue then you need to go for XSLT/Java mapping to format the SFDC response structure to your given MM structure.

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Hi Manoj K,

I tried above option but it didnt help, can you help with JAVA/XSLT map how should I proceed?

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

Will try it out , can you please provide :

  • Sample XML which is expected in Response Mapping put some dummy values and takes xml from OM test tab.
  • Current XML which you are getting from SFDC.
rasjoshi
Active Contributor
0 Kudos

Hi Manoj,

PFA attached XML files from PI and SFDC RESPONSE.

BR,

Rashmi

sfdc-resp.txt

pi-resp.txt

manoj_khavatkopp
Active Contributor
0 Kudos

Hi Rashmi,

The Response which PI is expecting is totally different from the one which SFDC is sending i was expecting a small changes but this is totally different .

Can you please make sure if you are using the correct XSD/WSDL/Structure for the response . please check this with SFDC team once and get the structure corrected in PI or in SFDC.

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Yes Manooj, this is what SFDC is sending and same WSDL I have imported in PI which they have provided....

rasjoshi
Active Contributor
0 Kudos

Just for my understanding, can SFDC send data in format which I can see in PI??

manoj_khavatkopp
Active Contributor
0 Kudos

Is it the same xml you get in response when you check/unckeck "Do not use soap envelope "

Because the XML which you have provided has complete soap envelope but in your case you just need to soap body content so can you please check if the xml in case when you check/unckeck "Do not use soap envelope " . and attach the xml for both the case here.

manoj_khavatkopp
Active Contributor
0 Kudos

No i dont think so that is standard format defined by SFDC and i doudt if they can modify for each customer.

rasjoshi
Active Contributor
0 Kudos

Hi All,

Could you please check above config and let me know if it needs any changes?

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

Have you corrected the Dynamic variable name from url to "TServerLocation " .

Below are the only standard Variable supported by SOAP:

br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Do I need to make changes in my UDF for below line -

String url=document.getElementsByTagName("serverUrl").item(0).getTextContent();

Or just need to put "TServerLocation" in ASMA of my actual RX SOAP Channel?

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

You use the below UDF for lookup i.e pass user id and password and get the session is and the target url.

{ String sessionId ="";
 try { Channel channel = LookupService.getChannel("BC_SFDC",Channel);
 SystemAccessor accessor = null;
 accessor = LookupService.getSystemAccessor(channel);
 String loginxml = " enterprise.soap.sforce.com\"> " + UserName + " " + Password + " ";
 //convert to inputsream InputStream inputStream = new ByteArrayInputStream(loginxml.getBytes());
 //do a SOAP lookup with input payload Payload payload = LookupService.getXmlPayload(inputStream);
 Payload SOAPOutPayload = null;
 /*The SOAP call is made here and the response obtained is in the SOAPOutPayload.*/ SOAPOutPayload = accessor.call(payload);
 /* Parse the SOAPPayload to get the SOAP Response back. */ InputStream inp = SOAPOutPayload.getContent();
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 /* Create DOM structure from input XML */ DocumentBuilder builder = factory.newDocumentBuilder();
 Document document = builder.parse(inp);
 //recover session id and url to send next request to SFDC NodeList sessionId1 = document.getElementsByTagName("sessionId");
 Node node = sessionId1.item(0);
 String url=document.getElementsByTagName("serverUrl").item(0).getTextContent();
 if (node != null) { node = node.getFirstChild();
 if (node != null) { sessionId = node.getNodeValue();
 } } } catch(Exception e) {e.printStackTrace();
 } return sessionId;
 }

Now once you have received the url you need to set this to the receiver soap channel which you need to do it via dynamic configuration . So your UDF should also have the below code.

{ String sessionId ="";
 try { Channel channel = LookupService.getChannel("BC_SFDC",Channel);
 SystemAccessor accessor = null;
 accessor = LookupService.getSystemAccessor(channel);
 String loginxml = " enterprise.soap.sforce.com\"> " + UserName + " " + Password + " ";
 //convert to inputsream InputStream inputStream = new ByteArrayInputStream(loginxml.getBytes());
 //do a SOAP lookup with input payload Payload payload = LookupService.getXmlPayload(inputStream);
 Payload SOAPOutPayload = null;
 /*The SOAP call is made here and the response obtained is in the SOAPOutPayload.*/ SOAPOutPayload = accessor.call(payload);
 /* Parse the SOAPPayload to get the SOAP Response back. */ InputStream inp = SOAPOutPayload.getContent();
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 /* Create DOM structure from input XML */ DocumentBuilder builder = factory.newDocumentBuilder();
 Document document = builder.parse(inp);
 //recover session id and url to send next request to SFDC NodeList sessionId1 = document.getElementsByTagName("sessionId");
 Node node = sessionId1.item(0);
 String url=document.getElementsByTagName("serverUrl").item(0).getTextContent();

*****************Dyanmic Config code**********************************

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//Create the TServerLocation key in namespace http://sap.com/xi/XI/System/SOAP. This key will hold the dynamically created URL

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/SOAP", "TServerLocation");
//Put the url value from the input in the configuration under the specified key
conf.put(key, url); 

*****************Dyanmic Config code**********************************

 if (node != null) { node = node.getFirstChild();
 if (node != null) { sessionId = node.getNodeValue();
 } } } catch(Exception e) {e.printStackTrace();
 } return sessionId;
 }

And in channel change it to : TServerLocation

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Thanks!!!! I will try this code and let you know results...

BR,

Rashmi

Former Member
0 Kudos

I have requested Basis team for TLS issue.

Meanwhile, can you help me in understanding if my scenario is correct.

ESR - Created manual header for Query Req message -

I am passing USER ID and PSWD as input to SOAP LOOKUP UDF which I have mapped to SESSION ID Field.

Please see previous comment for UDF details..

After this I have created 2 ICOs... 1 Dummy ICO carrying SOAP RCVR CC -

2nd ICO - carrying actual SI details -

SOAP CC -

Please let me know if you find any issue at interface level...

BR,

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

Hi Rashmi,

Everything looks fine , i believe you have set Dynamic UDF to set the URL which is coming from lookup along with session id . But i dobut if the variable url will work you need to set the dynamic URL for TServerLocation

You exact scenario is reflected here

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

I just checked logs and found below message, may be because of this I am unable to get SessionID back from lookup channel -

CLIENT: 44599 RESPONSE: - 974 bytes:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>sf:UNSUPPORTED_CLIENT</faultcode><faultstring>UNSUPPORTED_CLIENT: TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</faultstring><detail><sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault"><sf:exceptionCode>UNSUPPORTED_CLIENT</sf:exceptionCode><sf:exceptionMessage>TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</sf:exceptionMessage><sf:upgradeURL>https://ap5.salesforce.com/secur/weakhttps.jsp?l=1</sf:upgradeURL><sf:upgradeMessage>Stronger security is required</sf:upgradeMessage></sf:UnexpectedErrorFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

Any comment on this?

-

Rashmi

manoj_khavatkopp
Active Contributor
0 Kudos

Error itself is self descriptive . Your PI system is sending request with TLS 1.0 you need to upgrade it to higher version :

https://blogs.sap.com/2017/06/09/chronicles-of-a-tls-1.2-upgrade/

manoj_khavatkopp
Active Contributor
0 Kudos

Have you treid hitting the SFDC directly from SOAP UI and see what is the response ?

You can enable Trace in your receiver SOAP LOOKUP channel and then cross the paylaod with raw data of soap ui.

You may refer this blog

Br,

Manoj

rasjoshi
Active Contributor
0 Kudos

Hi Manoj,

Yes I did SOAP UI test and got response successfully....

I have followed your blog as well....

Below is my UDF -

{ String sessionId =""; try { Channel channel = LookupService.getChannel("BC_SFDC",Channel); SystemAccessor accessor = null; accessor = LookupService.getSystemAccessor(channel); String loginxml = "<login xmlns=\"urn:enterprise.soap.sforce.com\"> <username>" + UserName + "</username> <password>" + Password + "</password> </login>"; //convert to inputsream InputStream inputStream = new ByteArrayInputStream(loginxml.getBytes()); //do a SOAP lookup with input payload Payload payload = LookupService.getXmlPayload(inputStream); Payload SOAPOutPayload = null; /*The SOAP call is made here and the response obtained is in the SOAPOutPayload.*/ SOAPOutPayload = accessor.call(payload); /* Parse the SOAPPayload to get the SOAP Response back. */ InputStream inp = SOAPOutPayload.getContent(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); /* Create DOM structure from input XML */ DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(inp); //recover session id and url to send next request to SFDC NodeList sessionId1 = document.getElementsByTagName("sessionId"); Node node = sessionId1.item(0); String url=document.getElementsByTagName("serverUrl").item(0).getTextContent(); if (node != null) { node = node.getFirstChild(); if (node != null) { sessionId = node.getNodeValue(); } } } catch(Exception e) {e.printStackTrace(); } return sessionId; }

Do you see anything wrong here?