5

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

 1 year ago
source link: https://blogs.sap.com/2022/06/23/deploy-a-soap-server-locally-and-use-cpi-soap-adapter-to-send-message-to-it/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
June 23, 2022 3 minute read

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

9-28.png

Test soap server with Soap Ui

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

10-21.png

use soap ui to test soap server

11-20.png
13-18.png

Configure sap cloud connector to expose local soap server to CPI

14-13.png

Build and deploy Iflow in CPI

15-12.png
16-9.png

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;
}
17-8.png
<p2:MessageSplitterRequest xmlns:p2="http://tempuri.org/">
   <p2:message>${property.msg}</p2:message>
   <p2:splitter>${property.splitter}</p2:splitter>
</p2:MessageSplitterRequest>
18-6.png

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

19-6.png
21-4.png
20-5.png
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

22-3.png
23-3.png

Get URL from deployed Iflow:

24-3.png
25-3.png

Test in postman:

26-2.png
27-2.png

The End.

Best Regards!

Jacky Liu


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK