Skip to Content
Author's profile photo Midhun VP

Debugging Custom Script in Integration Gateway

Note: There is a known issue in this approach. Hence this will not work. I will update once it is fixed.

Some of the features that can be enabled using custom script in Integration Gateway (IGW) are: modify the requests and responses of an Odata request, handle delta token , multipart and composite WSDL support, and SOAP authentication. There are many examples in SCN on how to write custom script in Integration Gateway. In this blog I am explaining how to easily debug the script using IGW’s eclipse based tooling.

From SMP SP06, debugging of custom script written in JavaScript is possible (Groovy supports in future). I have created a simple project using the WSDL http://www.webservicex.net/medicareSupplier.asmx?WSDL. High level details of the project is given below. Here I am not explaining how to create a project but I am explaining how to debug the script used in the project.

Odata Entity:

ScreenHunter_36 Feb. 24 23.40.jpg

Custom Script written under function processRequestData

  //Import statements

   importPackage(com.sap.gateway.ip.core.customdev.logging);

   importPackage(com.sap.gateway.ip.core.customdev.util);

   importPackage(org.apache.olingo.odata2.api.uri);

   importPackage(java.util);

   importPackage(com.sap.gateway.core.ip.component.commons);

   importPackage(com.sap.gateway.ip.core.customdev.api);

   importPackage(org.apache.olingo.odata2.api.processor);

   //Getting value from header

   var context = message.getHeaders().get(“odatacontext”);

   var City = context.getRequestHeaders().get(“City”).get(0);

   var child = new LinkedHashMap();

   child.put(“key:City”, City);

   message.setBody(child);

   return message;

How to start debugging ?

  • Open prop.ini file of SMP server (C:\SAP\MobilePlatform3\Server)  and add the property -Drhino.debugger.port=9123

      ScreenHunter_36 Feb. 24 18.40.jpg

  • From eclipse, click on down arrow next to debug menu and choose debug configurations.

     Untitled2.png

If debug menu is not visible: Go to Windows > Customize Perspective. “Navigate to Commands group visibility” tab. Then select “Launch” option in the Availability Command Groups and click OK.

  • On the new window opened, provide below details:

     Untitled.png

  • Navigate to Source tab and provide the path to the script file and click on Debug.

    Untitled1.png

  • Open JavaScript file and set a break point as given below.

     Untitled3.png

  • Execute the Odata service from a rest client by passing City as header along with Authorization header.

ScreenHunter_36 Feb. 25 00.00.jpg

    

  • It triggers the break point set in the Javascript. To see the data send from rest client (ie. City) add Expression String(child) as given below. If Expressions tab not visible: Go to Windows > Show view > Expressions.

ScreenHunter_36 Feb. 24 23.59.jpg

Regards, Midhun

SAP Technology RIG

Assigned Tags

      12 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      This is great, will give it a try.

      thanks for sharing this

      Author's profile photo Fenil doshi
      Fenil doshi

      Hi Midhun,

      I have been doing this configuration, just 1 question as you are mentioning the host for script debuggin as localhost this is valid if the servcie is hosted on the same machine as Eclipse is, if remotely working then the host will change and equivalent port.

      Any insight on that ? It will be really helpful.

      Regards,

      Fenil.

      Author's profile photo Jitendra Kansal
      Jitendra Kansal

      Midhun VP

      Any inputs for this error? I have set 9123 port at both places, SMP and eclipse both are on same machine. I am able to telnet that port.

      Author's profile photo Vishnu Pankajakshan
      Vishnu Pankajakshan

      Hi Midhun VP,

      How abt a Remote server (Unfortunately mine is 🙂 ).Do i have a work around for debugging.I am using SMP 3.0 SP07 whether this supports debugging Groovy Script.

      Regards,

      Vishnu

      Author's profile photo Nagesh Caparthy
      Nagesh Caparthy

      Hi Midhun VP,

      I am getting error, "Failed to Parse Content length". Its a remote desktop and I am able to telnet the port also. Running on SMP3.0 SP07 PL02.

      Regards,

      Nagesh

      Author's profile photo Bheerendra Sahu
      Bheerendra Sahu

      Hi Midhun VP,



      I am getting error " Error occured while launching : Connection refused "

      Added the line in props.ini(-Drhino.debugger.port=9123)

      I am using same system for server and eclipse and tried with SP07 PL03 and SP08 both are giving same error.

      Would you please let me know if something else needs to be done ?

      @ Jitendra Kansal  : Did you get it working?  I am facing the same issue you commented above..

      Regards,

      Bheerendra Sahu

      Author's profile photo Former Member
      Former Member

      Any updates on the Connection Refused: Connect? I have the same issue on SP08.02

      Author's profile photo Midhun VP
      Midhun VP
      Blog Post Author

      Hi Niek,

      There is a known issue with this. I will update here once we fix it.

      Regards, Midhun

      SAP Technology RIG

      Author's profile photo Former Member
      Former Member

      Thnx, any idea on when to expect this update? A day, week, month? 😉

      Author's profile photo Vicente Veiga
      Vicente Veiga

      Any update regarding this method? I understand this is the only possible method to debug my javascript custom code for the service to be deployed in SMP3.0

      Is there any other way? Perhaps debugging the code directly in eclipse?

      Regards

      Author's profile photo Midhun VP
      Midhun VP
      Blog Post Author

      Hi Vicente,

      The solution to this issue would be available soon as a patch.

      Another, better option is to use a code snippet that records the logs in SMP server as mentioned in this blog: http://scn.sap.com/docs/DOC-58936

      More specifically under the section "How to debug".

      Regards, Midhun

      SAP Technology RIG

      Author's profile photo Binson V A
      Binson V A

      Hi,

      This solution has worked for me, both eclipse and SMP are on the same system. Also please make sure that you select the project name before activating debugging.

      Regards,

      Binson