on 10-19-2017 3:53 PM
Hello All,
I need an urgent help on calling external service using xsjs.
I am getting an error "Error: HttpClient.request: request failed: internal error occurred \"Failed to send request to socket...rc = -1\"".
I have read many blogs regarding this error and tried to replicate the same but still I am getting this error.
My scenario is like I need to call an SOAP webservice by passing username and password. If its authenticated successfully, the SOAP service will trigger an Email.
Also I have uploaded the required certificate on XS trust connection.
Please find my below code:
XSJS:
try {
var soapenv =
'<?xml version="1.0" encoding="utf-8"?>'+
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cxf="http://cxf.component.camel.apache.org/" xmlns:web="http://webservices.dsod.sap.com/">'+
'<soapenv:Header/>'+
'<soapenv:Body>'+
' <cxf:invoke>'+
' </cxf:invoke>'+
' <web:logonRequest>'+
' <userName>ABC</userName>'+
' <password>XYZ</password>'+
' </web:logonRequest>'+
'</soapenv:Body>'+
'</soapenv:Envelope>';
var dest = $.net.http.readDestination("com.system.test", "external");
var client = new $.net.http.Client();
var req = new $.web.WebRequest($.net.http.POST,"");
req.contentType = "text/xml";
req.setBody(soapenv);
client.request(req, dest);
var response = client.getResponse();
$.response.contentType = "application/json";
$.response.setBody(response);
}
catch (e) {
// return the error as JSON for debugging
var errorResponse = {"error": e.toString()};
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
$.response.contentType = "application/json";
$.response.setBody(JSON.stringify(errorResponse));
}
Can anyone please help me to figure out what I am actually missing here.
Regards,
Vicky
giri.sreerangam did a blog on a similar scenario
https://blogs.sap.com/2017/09/05/calling-soap-web-service-from-hana-xsjs/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.