This is a submission for the SAP Intelligent RPA Tutorial Challenge.
This blog post offers an overview of how a SOAP API can be used in SAP S/4HANA process bot using SAP Intelligent Robotic Process Automation . The template bots are delivered in SAP Best Practices Explorer “SAP Best Practices for SAP Intelligent Robotic Process Automation Integration with SAP S/4HANA“. For downloading the source code refer the release note 2788986 - Release Strategy for SAP Best Practices for SAP Intelligent Robotic Process Automation for SAP S/4HANA.
Below are the template bots having SOAP API call:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Header>
...
</soap:Header>
<soap:Body>
...
<soap:Fault>
...
</soap:Fault>
</soap:Body>
</soap:Envelope>
//function to construct the XHR object
function getXhr() {
var xhr = null;
try {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
ctx.log("getXhr new ActiveXObject('Msxml2.XMLHTTP')");
} catch (e) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
ctx.log("getXhr new ActiveXObject('Microsoft.XMLHTTP')");
} catch (e) {
xhr = new window.XMLHttpRequest();
ctx.log("getXhr new window.XMLHttpRequest()");
}
}
return xhr;
} catch (e) {
ctx.log(" *** getXMLHTTPRequest *** " + e.description);
return null;
}
};
//a custom method for handling SOAP API call
function soapApiCall() {
var xhr = getXhr();
/** form a custom object
*with the mandatory information
*required for the API call,
*like URL, payload, etc.
*/
var request = {
apiUrl: apiEndPoint,
/**payloadProject value
*contains XML format payload
*of the SOAP Envelope
*/
apiPayload: payloadProject,
communicationUser :communicationUser,
communicationPassword : communicationPassword
};
try {
postCall(xhr, request);
}
catch (e) {
ctx.log("SOAP API Call Failed");
return ;
}
var status = xhr.status;
ctx.log("Status " + status);
var statusText = xhr.statusText;
ctx.log("Status Text : " + statusText);
ctx.log("xhr: " + xhr);
var responseText = xhr.responseText;
ctx.log("response: " + responseText);
var rawResponse = xhr.responseXML;
ctx.log("raw xml : " + rawResponse);
rootData.soapResponse = rawResponse;
var soapJsonResponse = ctx.xml.xml2json(rootData.soapResponse, "");
var jsonResponse = ctx.json.stringify(soapJsonResponse, null, 4);
}
//function which handles the POST call request
function postCall(xhr, request) {
xhr.open("POST", request.apiUrl, false);
//Set All the Required Headers
xhr.setRequestHeader('Content-Type', 'text/xml');
if (request.communicationUser != '' && request.communicationPassword != '') {
xhr.setRequestHeader("Authorization", "Basic " + ctx.base64.encode(request.communicationUser + ':' + request.communicationPassword));
}
xhr.setRequestHeader("Accept", "*/*");
ctx.log(request.apiPayload);
xhr.send(request.apiPayload);
};
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 |