Skip to Content
avatar image
Former Member

HANA XS JS - Web service call error

Hi, I'm calling a web service from XS Engine but I get a socket error as follows please help.

Basically the Http Request is not taking place - Request not sent !

I checked the ports and set XS engine to debug mode.

Error Message :

HttpClient.request: request failed: internal error occurred "Failed to send request to socket...rc = -1"

Http Dest and XS JS File:

host = "https://hcids.ap1.hana.ondemand.com/DSoD/webservices";
port = 80; 
description = "DS On Demand";
useSSL = false;
authType = none;
useProxy = false;
proxyHost = "";
proxyPort = 0;
timeout = 30000;
// XS JS File

var destination_package = "File_Import.xsjs";
var destination_name = "service_destination";


try {
var soapenv = "";
soapenv = soapenv.concat("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://webservices.dsod.sap.com/\">");
soapenv = soapenv.concat("<soapenv:Header/>");
soapenv = soapenv.concat("<soapenv:Body>");
soapenv = soapenv.concat(" <web:logonRequest>");
soapenv = soapenv.concat("    <orgName>MY_ORGS</orgName>");
soapenv = soapenv.concat("   <userName>name@mailid.com</userName>");
soapenv = soapenv.concat("   <password>mypassword</password>");
soapenv = soapenv.concat("   <isProduction>false</isProduction>");
soapenv = soapenv.concat(" </web:logonRequest>");
soapenv = soapenv.concat("</soapenv:Body>");
soapenv = soapenv.concat("</soapenv:Envelope>");

var dest = $.net.http.readDestination(destination_package, destination_name);
var client = new $.net.http.Client();
var req = new $.web.WebRequest($.net.http.POST, soapenv);
client.request(req, dest);
var response = client.getResponse();
if (response.body)
{
$.response.setBody(response.body.asString());
}
else 
{
$.response.setBody("error");
}
$.response.status = response.status;
$.response.contentType = "text/xml; charset=utf-8";
}
catch (x) 
{
$.response.status = 500;
$.response.setBody(x.message);
}
Add comment
10|10000 characters needed characters exceeded

  • Vyas,

    are you getting any timeout ? are you able to ping the destination? connection lost seems more like a timeout error rather than a non-reachable error

  • Former Member Sergio Guerrero

    Hi Sergio,

    Yes I'm able to ping the destinations and make calls using SOAP UI as well. Assuming this was a problem due to a specific web service, I tried with 2-3 different services still the same result.

  • did you try increasing the timeout to see if that would help?

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 15, 2016 at 12:15 PM

    Hi Vyas,

    Seems like you are trying to access a webservice at "https://hcids.ap1.hana.ondemand.com/DSoD/webservices".

    • Starting with the host, it should be ap1.hana.ondemand.com.
    • I tried to access the web service with the mentioned host and port that you have used in the destination file via a browser REST client.
    • It seems like there is a 302 redirect that points you to https version of the URL. This means that even if you have your destination pointing to port 80, you'll be forced to port 443 (https). Also need to set useSSL = true.
    • The error that you mentioned could be because of a missing trust store. Since you are accessing a HTTPS url, you need to upload the certificate of the host (ap1.hana.ondemand.com) to the trust store (access it via XS Admin) and use it.

    Apart from that, set the request headers and payload properly. This should let you access the web service.

    That should solve your problem.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 12, 2016 at 12:28 PM

    Well for one your host you specified is HTTPS but the port you specified is 80. That seems wrong. Plus you said use SSL was false. I think you have some mismatch in your destination parameters.

    Add comment
    10|10000 characters needed characters exceeded