cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript ajax call to SAP PI

Former Member
0 Kudos

Hi,

I need to build an interface to SAP (housed on our company network) from a cloud platform. SAP PI version 7.4 is installed in our landscape and is our preferred way to interface with SAP. My intent is to make a cross domain JQuery / Ajax call to PI.

Although, there are lot of articles on how to make a cross domain call, but none specifies how exactly the call should be made and what all information one should pass in the Header of the post request in Ajax call and what should be the URL in post request.

Sometime back, i had made JQUERY / ajax call to SAP by using SAP mobile server on CRM and that had worked, but i am struggling here and literally clueless.

This is how my code looks. When i run this code, i see that the request reaches the server, but it gives and 401 unauthorized error OR 405 method not found in one case when i changed the URL.

I would really appreciate help.

/***code

jQuery.ajax({type: "POST",

  url: 'http://ipaddress:51000/XISOAPAdapter/MessageServlet?ximessage=true',

  contentType: "text/xml",

  dataType: "xml",

  data : soapMessage,

  enableLogging: true,

headers:

  {

  'Authorization': 'Basic ' + btoa('arteria:apollo22')

  },

  success: function (response)

  {

     alert ("success");

     console.log(response);

  },

    

  error: function (response)

  {

       alert ("error");

      console.log(response);

  }

});

****/

regards

dinesh Rampal

Accepted Solutions (0)

Answers (2)

Answers (2)

vinaymittal
Contributor
0 Kudos

can you give this ({type: "POST", (POST)in single quotes

see this link below

http://www.c-sharpcorner.com/UploadFile/deveshomar/calling-webservice-using-ajax-jquery-with-soap-me...

what is soapMessage variable where have you defined it..as in the link above...

see this one

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Dinesh,

I suggest you download first SOAP UI. The PI wsdl can be generated by going to the ICO and then select display wsdl. Once done, load the wsdl into SOAP UI, generate a request and then click the play button.

The raw tab will contain the HTTP Headers that you will need when posting.

Regards,

Mark

Former Member
0 Kudos

Hi Mark

Thanks for the reply. I could make some progress but the error has changed. I am now getting an Java Adapter error and it points to "unable to determine mapping...".  (see last line of the paste of error!)

Would you know, Is this a PI specific error or a configuration error in PI to handle my call. Any inputs will be appreciated!

regards

dinesh

------ RAW out of SOAP UI.

HTTP/1.1 500 Internal Server Error

server: SAP NetWeaver Application Server 7.42 / AS Java 7.40

set-cookie: MYSAPSSO2=AjExMDAgAA5wb3J0YWw6YXJ0ZXJpYYgAB2RlZmF1bHQBAAdBUlRFUklBAgADMDAwAwADUElEBAAMMjAxNTA5MTQxMTAyBQAEAAAACAoAB0FSVEVSSUH%2FAQQwggEABgkqhkiG9w0BBwKggfIwge8CAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHATGBzzCBzAIBATAiMB0xDDAKBgNVBAMTA1BJRDENMAsGA1UECxMESjJFRQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTUwOTE0MTEwMjE2WjAjBgkqhkiG9w0BCQQxFgQUkYwI!dTdYzQpBrOGKcYSew0m44gwCQYHKoZIzjgEAwQuMCwCFHfSKuWTI4!8DvnVtL6CgjOKIrEBAhQXTCFYr!Imqw7w4YgkoFUIgQtytQ%3D%3D;path=/;domain=.apollotyres.com;HttpOnly

content-type: text/xml; charset=utf-8

content-encoding: gzip

date: Mon, 14 Sep 2015 11:02:16 GMT

set-cookie: com.sap.engine.security.authentication.original_application_url=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; path=/XISOAPAdapter; HttpOnly

set-cookie: JSESSIONID=0PcKCdAEiJAA8rDElFRP0alwBIXLTwHyQlEG_SAPNY9J-QIX_b9-g59ANmVMJ7AH; Version=1; Path=/

set-cookie: JSESSIONMARKID=MSEEswr1wcBuM7oKNg2ddbGQ6pjFTUYOolN_JCUQY; Version=1; Path=/

Content-Length: 1095

Age: 207

Via: 1.1 CORPPXYS02.apollotyres.com

<?xml version='1.0'?>

<!-- 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><![CDATA[

com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error encountered while executing mapping: com.sap.aii.af.service.mapping.MappingException: com.sap.aii.utilxi.misc.api.ResourceException: Could not determine mapping steps for message 49f2a65c-13a3-4c79-1ef3-9585f2125bdd

iaki_vila
Active Contributor
0 Kudos

Hi Dinesh,

The error can be thrown for different causes, the more commons are that you are not using the right payload then the mappings can not be done correctly. Also, if the endpoint is generating an exception the response mapping can not be done correctly. Check the payloads in the PI monitoring.

Regards.

Former Member
0 Kudos

Hi Inaki

My request is not even reaching PI. Hence, I cannot look at the monitor and find out the exception. I presume the error is somewhere in my ajax call (which i pasted in my orginal post), but i am not able to find out..what could be wrong!

Would you or any other expert know or have any clue about this ?

regards

dinesh

vinaymittal
Contributor
0 Kudos

Hi Dinesh,

Did you generate the webservice url from ICO ? because it doesnt look to me a proper url for the WSDL.

Correct format of URL is

http://<host>:<port>/XISOAPAdapter/MessageServlet?channel=:<sender Business system>:<sender communication chanel name>


remove the < >


also when you generate the wsdl in the wsdl you will have the request message structure , make sure soapMessage variable has the payload for request in that format.

Regards

Vinay

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Dinesh,

You can look at RWB -> CC Monitoring.

Regards,

Mark