Skip to Content
Technical Articles
Author's profile photo Jacky Liu

Deploy a soap server locally and use CPI SOAP Adapter to send message to it

Today I supported a customer who want to build https proxy for third party sequence SOAP API calls and then call the the https proxy in an application .  This is new method to simplify the backend development .   I want to take this blog to demo an end to end SOAP API call in CPI .

I assume the readers have the following pre-requisits:

  1.  Have installed node .
  2.  Have installed git .
  3.  Have installed and configured  SAP clound connector .
  4.  Have installed  SOAP UI
  5.  Have installed Postman .

The following  is the steps for the end 2 end demo:

  1. Deploy local soap server
  2. Test soap server with Soap Ui
  3. Configure sap cloud connector to expose local soap server to CPI
  4. Build and deploy Iflow in CPI
  5. Test Iflowing with postman

Deploy local soap  server

git clone https://github.com/officer-rosmarino/node-soap-example.git

cd node-soap-example

npm install

node app.js

Test soap server with Soap Ui

download wsdl file with url: http://localhost:8000/wsdl?wsdl

use soap ui to test soap server

Configure sap cloud connector to expose local soap server to CPI

Build and deploy Iflow in CPI

The following is the code for step Groovy script 2

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.JsonSlurper;
import groovy.json.JsonOutput;
import groovy.json.*;

def Message processData(Message message) {
    //Body
    def body = message.getBody(java.lang.String) as String;
    def jsonSlurper = new JsonSlurper();
    def jsonbody = jsonSlurper.parseText(body);
    def msg = jsonbody.message;
    def splitter = jsonbody.splitter;
    
    //Properties
    message.setProperty("msg", msg);
    message.setProperty("splitter", splitter);
    return message;
}

 

<p2:MessageSplitterRequest xmlns:p2="http://tempuri.org/">
   <p2:message>${property.msg}</p2:message>
   <p2:splitter>${property.splitter}</p2:splitter>
</p2:MessageSplitterRequest>

the address and location id come from the following screen shot in BTP cockpit :

 

 

 

import com.sap.gateway.ip.core.customdev.util.Message;

def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;

    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){

        messageLog.setStringProperty("Logging", "Printing Payload As Attachment");
        messageLog.addAttachmentAsString("Message#1", body, "text/plain");

    }
    return message;
}

 

Test Iflowing with postman

Get oauth2 information from  cpi runtime service key

 

Get URL from deployed Iflow:

 

Test in postman:

 

 

The End.

 

Best Regards!

Jacky Liu

 

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Graversen
      Daniel Graversen

      Hi Jacky.

       

      That is a pretty cool NPM solution. I could imagine you could also run it in BTP Cloud Foundry where you also have the option to use NPM and expose test web services. But I guess for a development test it probably does not matter that much.

      And you can also skip the Oauth token and just put the client id/secret as username password in the post request

      If you just want to mock services, then Figaf can automate the creation of mocked iflows and mocking the endpoints.

       

      DAniel

      Author's profile photo Jacky Liu
      Jacky Liu
      Blog Post Author

      Hi, Daniel,

      Thanks for your suggestion!

      You are right ! I can deploy the soap server in BTP cloud foundry  or  BTP Kyma .    I can use basic authorization also .

      I just checked Figaf  and you have given wonderful webnar for it . It is system forcus on CI/CD and transport as my understanding. BTP has enbeded CI/CI and transportation service to support this also .

      Best regards!

      Jacky Liu