Skip to Content
Author's profile photo Midhun VP

How to use Composite WSDL in Integration Gateway

Using Integration Gateway SOAP can be converted to Odata protocol. If the WSDL used is of type composite, it has to be managed via custom script because the Integration Gateway design time tool will not support mapping of composite WSDL. This guide is on how to use a composite WSDL in Integration Gateway using custom script.

Prerequisites

Create SMP Odata Implementation Project

  • Open Eclipse and select File > New > SAP Mobile Platform Odata Implementation Project.
  • In the pop up window provide the project name “GetStockQuote”.
  • Select Target Runtime Server as “SAP Mobile Platform 3.0 SP5”.

/wp-content/uploads/2015/01/1_633323.png

  • Click Next.

/wp-content/uploads/2015/01/1_633323.png

  • Enter Model name “StockQuote”.
  • Choose Model content “Blank Odata Model”.
  • Click Finish. It creates the GetStockQuote project in the workspace.

/wp-content/uploads/2015/01/1_633323.png

Create Entity Set

  • From the palette tab choose “Entity Type”, and then click on the empty area under the opened StockQuote.odata file. It creates an entity set.

/wp-content/uploads/2015/01/1_633323.png

  • Change the name of the Entity Type to StockQuote.
  • Rename existing property name StockQuoteID to Symbol.
  • Keep the cursor on the entity type to show more options. Then click on Add Property.

/wp-content/uploads/2015/01/1_633323.png

  • In the properties tab change the name to “Last”.

/wp-content/uploads/2015/01/1_633323.png

  • Add all other properties: Date, Time and Name.

/wp-content/uploads/2015/01/1_633323.png

Write Custom Script for Query

  • In the Project Explorer right click on StockQuote.odatasrv file > Select Data Source.

/wp-content/uploads/2015/01/1_633323.png

  • Select Query from Operations and select SOAP Service as Data source.

/wp-content/uploads/2015/01/1_633323.png

  • Click Next.
  • Browse WSDL file stored in local machine and select the operation “GetStockQuote”.

/wp-content/uploads/2015/01/1_633323.png

  • Click Finish.
  • Expand StockQuote.odatasrv file > Right click on Query > Define Custom Code.

/wp-content/uploads/2015/01/1_633323.png

  • Choose JavaScript as Script type and click Finish.

/wp-content/uploads/2015/01/1_633323.png

  • Place the below code under the function processRequestData

      importPackage(java.lang);

      importPackage(java.util);

      var map = new LinkedHashMap();

      map.put(“key:request”, “SAP”);    //Passing input to query.

       message.setBody(map);


  • Place the below code under the function processResponseXML

importPackage(org.apache.camel.component.cxf);

       importPackage(java.util);

       importPackage(java.lang);

       importPackage(javax.xml.transform.dom);

       importPackage(org.w3c.dom);

//Creating response for the query

        var payload = message.getBody().toString();

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

        log.logErrors(LogMessage.TechnicalError, “Response Payload is: “ + payload);

        var tokens = payload.split(“(?=<)|(?<=>)”);

        var buffer = new StringBuffer();

        buffer.append(“<?xml version=\”1.0\” encoding=\”UTF-8\”?>”);

        buffer.append(“<StockQuoteSet><StockQuote>”);

        var breakLoop = false;

        for(var i=0;i<tokens.length;i++)

         {

               log.logErrors(LogMessage.TechnicalError, “token length is : “ + tokens.length.toString());

               log.logErrors(LogMessage.TechnicalError, ” token name is : “ + tokens[i]);

               if(tokens[i].contains(“Symbol”) && !breakLoop)

               {

               buffer.append(“<Symbol>”);

               buffer.append(tokens[i+1]);

               buffer.append(“</Symbol>”);

               i=i+2;

               breakLoop = true;

               }

               if(tokens[i].contains(“Last”))

               {

               buffer.append(“<Last>”);

               buffer.append(tokens[i+1]);

               buffer.append(“</Last>”);

               i=i+2;

               }

               if(tokens[i].contains(“Date”))

               {

               buffer.append(“<Date>”);

               buffer.append(tokens[i+1]);

               buffer.append(“</Date>”);

               i=i+2;

               }

               if(tokens[i].contains(“Time”))

               {

               buffer.append(“<Time>”);

               buffer.append(tokens[i+1]);

               buffer.append(“</Time>”);

               i=i+2;

               }

               if(tokens[i].contains(“Name”))

               {

               buffer.append(“<Name>”);

               buffer.append(tokens[i+1]);

               buffer.append(“</Name>”);

               i=i+2;

               }

              }

      buffer.append(“</StockQuote></StockQuoteSet>”);

       message.setBody(buffer.toString());


  • Save the file.

Deploy to SMP Server

  • To setup the connection to SMP server click on Windows > Preferences > Expand SAP Mobile Platform Tools > Server.
  • Provide below details:

URL: https://<smphostname>:8083

User: smpAdmin

Password: s3pAdmin

/wp-content/uploads/2015/01/1_633323.png

  • Click on Test Connection.

/wp-content/uploads/2015/01/1_633323.png

  • Right click on the project > Generate and Deploy Integration Content.

/wp-content/uploads/2015/01/1_633323.png

/wp-content/uploads/2015/01/1_633323.png

Test your service

  • Login to SAP Gateway Cockpit.
  • Under Services tab find the GETSTOCKQUOTE.

/wp-content/uploads/2015/01/1_633323.png

  • Click on Open Service Document to see the service document of the Odata service created.

ScreenHunter_20 Jan. 24 01.47.jpg

  • Append Odata collection name with the service document execute the query operation and get the data. https://<smpserverhotname>:8083/gateway/odata/SAP/GETSTOCKQUOTE;v=1 /StockQuoteSet


Untitled.png

Assigned Tags

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

      Hi Midhun,

      We tried your code, it works also, but it has only first entry in response where as we are having multiple set of record in response. for your case also its showing only single set of record.

      Can you please help us.