Technical Articles
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:
-
Have installed node .
-
Have installed git .
-
Have installed and configured SAP clound connector .
-
Have installed SOAP UI
-
Have installed Postman .
The following is the steps for the end 2 end demo:
-
Deploy local soap server
-
Test soap server with Soap Ui
-
Configure sap cloud connector to expose local soap server to CPI
-
Build and deploy Iflow in CPI
-
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
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
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