cancel
Showing results for 
Search instead for 
Did you mean: 

LookUp Exception in Java Mapping PI 7.3

Former Member
0 Kudos

Hi Experts,

This is an IDOC to Web Service Scenario where in we are using Message mapping and Java Mapping.

We are using Java Mapping for Calling the soap adapter which gets the session id from 3rd party. Then we build the custom soap header using this session id in java mapping. This payload is sent through another soap channel which is configures in the ID reciever communication channel.

We are getting the below error in Operation Mapping:

  • com.sap.aii.mapping.lookup.LookupException: Exception during processing the payload. Error when calling an adapter by using the communication channel SOAP_GetSessionId_NewReceiver (Party: , Service: SFDC, Object ID: d722599711af3766af5b40493aa27e37) XI AF API call failed. Module exception: 'java.lang.NullPointerException: while trying to invoke the method com.sap.aii.af.service.cpa.Binding.getObjectId() of an object loaded from local variable 'binding''. Cause Exception: 'while trying to invoke the method com.sap.aii.af.service.cpa.Binding.getObjectId() of an object loaded from local variable 'binding''.

We are using the below piece of code:

   /* method is to login to SFDC with the username and password to get the sessionId from the response*/

      private void getSessionIdFromSFDC(String username, String password)

      {

           // AbstractTrace atTrace = null;

            //atTrace = (AbstractTrace) map.get(StreamTransformationConstants.MAPPING_TRACE);

            try

            {

             getTrace().addDebugMessage("******* My trace starts here for getSessionIdFromSFDC *******");

                  Channel channel = LookupService.getChannel("SFDC","SOAP_GetSessionId_NewReceiver");

                  getTrace().addDebugMessage("channel="+channel);

                  SystemAccessor accessor = null;

                  accessor = LookupService.getSystemAccessor(channel);

                  getTrace().addDebugMessage("accessor"+accessor.toString());

                  getTrace().addDebugMessage("******* create login xml  *******");

                  String loginxml = "<login xmlns=\"urn:enterprise.soap.sforce.com\"> <username>"

                        + username

                        + "</username> <password>"

                        + password

                        + "</password> </login>";

                  getTrace().addDebugMessage("******* login xml created  *******");

                  getTrace().addDebugMessage("LogInXML"+loginxml);

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

                  getTrace().addDebugMessage("inputStream"+inputStream);

                  Payload payload = LookupService.getXmlPayload(inputStream);

                  getTrace().addDebugMessage("payload"+payload);

                  getTrace().addDebugMessage("payload"+payload.toString());

                  Payload SOAPOutPayload = null;

                  getTrace().addDebugMessage("******* Call accessor  *******");

                  SOAPOutPayload = accessor.call(payload);

                  getTrace().addDebugMessage("******* get SOAPOutPayload  *******"+ SOAPOutPayload);

                  getTrace().addDebugMessage("******* get content  *******");

                  InputStream inp = SOAPOutPayload.getContent();

                  getTrace().addDebugMessage("******* get DOM instance *******");

                  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

                  DocumentBuilder builder = factory.newDocumentBuilder();

                  Document document = builder.parse(inp);

                  NodeList sessionId1 = document.getElementsByTagName("sessionId");

                  Node node = sessionId1.item(0);

                  if (node != null)

                  {

                        node = node.getFirstChild();

                        if (node != null)

                        {

                         getTrace().addDebugMessage("******* get session id  *******");

                              sessionId = node.getNodeValue();

                        }

                  }

            }

            catch(Exception e)

            {getTrace().addDebugMessage("******* Excepitionraised *******"+e.toString());

                  e.printStackTrace();}

      }

Looks like We are getting the error while executing the line

SOAPOutPayload = accessor.call(payload);

as all the trace before this line is printed.

Please help as this is very urgent.

Thanks.

Pooja

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Pooja,

We have 7.31 SP03 and had several issues with performing SOAP Lookups.  We created a ticket with SAP and had to load the latest patches for both the "Adapter Framework" and "Message Component" for our SP03 level.  This resolved our problem.

I took the code you pasted above and replaced it in our code and it works great.  So the code you have works its not that.  The only other thing it could be would be your communication channel how it was created or cache issue but any cache issues should have been resolved by now since I'm sure you have had several reboots.

Thanks,

Steve D

masjo
Explorer
0 Kudos

Hi Pooja

Please refer to this thread which has solved my issue

http://scn.sap.com/thread/3239187

Former Member
0 Kudos

Hi J M,

I created the dummy serivice interface in IR and the receiver agreement in ID and included it in my java mapping but i am still getting the same exception.

The sap note asks to update the patch sap_xiaf SP05 patch 26 but we are already on sap_xiaf05 patch 30.

Let me know if we can do anything else.

This is very important and a solution would be appreciated.

Thanks for your help.

Thanks.

Pooja

bhavesh_kantilal
Active Contributor
0 Kudos

Hello Pooja,

As per your response in the other thread, you have mentioned you have changed the Java Mapping to use the new Service Interface.

I am not sure I understand this statement.

There  should be no change required to your XI 3.0 Code,i.e, the Lookup API works as-is with no code change.

As long as the channel is used in a Receiver Agreement, this should work. Can you provide us with the code change you have done to check better?

Regards,

Bhavesh

bhavesh_kantilal
Active Contributor
0 Kudos

Additional Note : We are on Patch 26. We did not go to a later patch as the rest of the scenarios / issues are not relevant to us and we did not want to repeat all our testing all over again.

How was the issue with the SOAP Receiver Cert Peer Rejection resolved? Was it another patch? I hope not!

Regards,

Bhavesh

Former Member
0 Kudos

Hi Bhavesh,

I have included the operation name and namespace(two lines in bold)in the below code. This is the old code, compiled with java 1.6. Created a receiver agreement in ID and used the same channel as in below java code in the receiver agreement.

Still facing the same issue.

public class sfdcSoapLookup1 implements StreamTransformation
{
      String sessionId ="";
      String prefix = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:Messages xmlns:ns0=\"http://sap.com/xi/XI/SplitAndMerge\"><ns0:Message1>" ;
      String soapEnvelopPrefix = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:enterprise.soap.sforce.com\">"+
      "<soapenv:Header> "+
      "<urn:SessionHeader>"+
      "<urn:sessionId> ";
      String soapEnvelopSuffix = "</urn:sessionId> </urn:SessionHeader> </soapenv:Header> <soapenv:Body>";
      String soapEnvelopeEnd = "</soapenv:Body> </soapenv:Envelope>";
      String strEnd = " </ns0:Message1></ns0:Messages>";


      private Map map;
      /* method setParamters is required, but we do not anything with it*/
      public void setParameter(Map param)
      {
     
            map = param;
      }
      public void execute(InputStream in, OutputStream out)
      {
    AbstractTrace atTrace1 = null;
    atTrace1 = (AbstractTrace) map.get(StreamTransformationConstants.MAPPING_TRACE);
    //Get system name
    String sysName = (String) System.getProperty("SAPSYSTEMNAME");
    atTrace1.addWarning("SystemName"+sysName);
     
      //Value mapping constants
  
   
String context = "http://sap.com/xi/XI";
atTrace1.addWarning("Getting context"+context);
String senderAgency = "SFDC";
atTrace1.addWarning("Getting senderAgency"+senderAgency);
String senderScheme = "SYSTEMNAME";
atTrace1.addWarning("Getting senderScheme"+senderScheme);
String receiverAgencyUser = "SFDCAgencyUser";
atTrace1.addWarning("Getting receiverAgencyUser"+receiverAgencyUser);
String receiverSchemeUser = "SFDCSchemeUser";
atTrace1.addWarning("Getting receiverSchemeUser"+receiverSchemeUser);
String receiverAgencyPwd = "SFDCAgencyPass";
atTrace1.addWarning("Getting receiverAgencyPwd"+receiverAgencyPwd);
String receiverSchemePwd = "SFDCSchemePass";
atTrace1.addWarning("Getting receiverSchemePwd"+receiverSchemePwd);
     
      IFIdentifier src = XIVMFactory.newIdentifier(context, senderAgency, senderScheme);
      IFIdentifier dstUser = XIVMFactory.newIdentifier(context, receiverAgencyUser , receiverSchemeUser);
      IFIdentifier dstPwd = XIVMFactory.newIdentifier(context, receiverAgencyPwd , receiverSchemePwd);
     
     
      String UserName = "";
      String Password = "";


            try
            {
            //Call value mapping to get user id and password
           
             try
             {
            atTrace1.addWarning("Calling XIVMService for username and password");
      UserName = XIVMService.executeMapping(src, dstUser, sysName);
      Password = XIVMService.executeMapping(src, dstPwd, sysName);
      atTrace1.addWarning("UserName"+UserName);
      atTrace1.addWarning("Password"+Password);
        }
        catch (ValueMappingException e)
        {
         UserName = "support+bbd@nubik.ca.sandboxba";
               Password = "bbdnubik789mSQyXptg1EpAheK94BaNsfhh";
            
        }
       
            atTrace1.addWarning("Calling method getSessionIdFromSFDC");
                  getSessionIdFromSFDC(UserName,Password); //Supply the SFDC developer account username and password.
                  copyPayload(in,out);
            }
            catch (Exception t)
            {
         
             t.printStackTrace();
            }
      }
      /* method is to build the Soap envelope for the input message payload */
      private void copyPayload(InputStream in, OutputStream out) throws StreamTransformationException
      {
                                               
                  try
                  {
                  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                  DocumentBuilder builder = factory.newDocumentBuilder();
                  Document doc = builder.parse(in);
                 
                  /*Provide your message type name in place of ns1:MT_HRInfo*/
                 
                  NodeList children = doc.getElementsByTagName("");
                 
                  if(doc.getElementsByTagName("ns1:ImportContact").getLength()!= 0)
                  {
                         children = doc.getElementsByTagName("ns1:ImportContact");
                  }
                  else if(doc.getElementsByTagName("ns2:ImportContact").getLength()!= 0)
                  {
                         children = doc.getElementsByTagName("ns2:ImportContact");
                  }
                  else if(doc.getElementsByTagName("ns2:ImportHRBP").getLength()!= 0)
                  {
                         children = doc.getElementsByTagName("ns2:ImportHRBP");
                  }


                  /*Create out payload*/
                 
                  out.write(prefix.getBytes());
                  for(int i=0;i<children.getLength();i++)
                  {
                        out.write(soapEnvelopPrefix.getBytes());
                        out.write(sessionId.getBytes());
                        out.write(soapEnvelopSuffix.getBytes());
                        out.write(children.item(i).toString().getBytes("UTF-8"));
                        out.write(soapEnvelopeEnd.getBytes());
                                         
                  }
                  out.write(strEnd.getBytes());
                  }
     
            catch (Exception e)
            {
                  throw new StreamTransformationException(e.getMessage());
            }
      }


      /* method is to login to SFDC with the username and password to get the sessionId from the response*/
      private void getSessionIdFromSFDC(String username, String password)
      {
            AbstractTrace atTrace = null;
            atTrace = (AbstractTrace) map.get(StreamTransformationConstants.MAPPING_TRACE);
            try
            {
                  atTrace.addWarning("******* My trace starts here for getSessionIdFromSFDC *******");
                  Channel channel = LookupService.getChannel("SFDC","SOAP_GetSessionId_NewReceiver");
                  SystemAccessor accessor = null;
                  accessor = LookupService.getSystemAccessor(channel);
                  atTrace.addWarning("******* create login xml  *******");
                  String loginxml = "<login xmlns=\"urn:enterprise.soap.sforce.com\"> <username>"
                        + username
                        + "</username> <password>"
                        + password
                        + "</password> </login>";
                  atTrace.addWarning("******* login xml created  *******");
                  atTrace.addWarning("LogInXML"+loginxml);
                  InputStream inputStream = new ByteArrayInputStream(loginxml.getBytes());
                  Payload payload = LookupService.getXmlPayload(inputStream);
                  Payload SOAPOutPayload = null;
                  accessor.setOperationName("SI_IS_Token");
                  accessor.setOperationNamespace("http://bombardier.com/Interface/HRData");
                  atTrace.addWarning("******* Call accessor  *******");
                  SOAPOutPayload = accessor.call(payload);
                  //atTrace.addWarning("******* get content  *******");
                  InputStream inp = SOAPOutPayload.getContent();
                  atTrace.addWarning("******* get DOM instance *******");
                  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                  DocumentBuilder builder = factory.newDocumentBuilder();
                  Document document = builder.parse(inp);
                  NodeList sessionId1 = document.getElementsByTagName("sessionId");
                  Node node = sessionId1.item(0);
                  if (node != null)
                  {
                        node = node.getFirstChild();
                        if (node != null)
                        {
                              atTrace.addWarning("******* get session id  *******");
                              sessionId = node.getNodeValue();
                        }
                  }
            }
            catch(Exception e)
            {atTrace.addWarning("******* Excepitionraised *******"+e.toString());
                  e.printStackTrace();}
      }
     
}

Please let me know if anything is not correct.

Thanks.

Pooja

bhavesh_kantilal
Active Contributor
0 Kudos

Pooja,

Can you let me know why you are adding this info? For the SOAP Lookup to work, as long as a Receiver Agreement exists the same should work. On our end we do not add any Operation Name n the mapping to the accessor object.

accessor.setOperationName("SI_IS_Token");

accessor.setOperationNamespace("http://bombardier.com/Interface/HRData");

Try removing this code, and ensure that the SOAP Receiver Adapter SFDC --> SOAP_GetSessionId_NewReceiver in your case is used in a Receiver Agreement.

The Interface Name and Namespace in the receiver agreement can be anything and the same need not be referenced within your Look Up code.

Regards,

Bhavesh

masjo
Explorer
0 Kudos

Hi Pooja

I am currently developing the exact same scenario and am also failing at the same line of code.  My error is:

  • com.sap.aii.mapping.lookup.LookupException: Exception during processing the payload. Error when calling an adapter by using the communication channel SOAP_Receiver_UserSFLoginRequest (Party: , Service: SALESFORCE_DEV, Object ID: 062db5d582653ffc9d3a7b4f3b7237e1) XI AF API call failed. Module exception: 'com.sap.aii.af.service.cpa.CPAObjectNotFoundException: Couldn't retrieve outbound binding for the given P/S/A values: FP=;TP=;FS=Mapping;TS=SALESFORCE_DEV;AN=;ANS=; in the current context [Unknown]. '. Cause Exception: 'Couldn't retrieve outbound binding for the given P/S/A values: FP=;TP=;FS=Mapping;TS=SALESFORCE_DEV;AN=;ANS=; in the current context [Unknown]. '.

I would be very interested to know how you solve your issue as I am stuck myself!