Skip to Content
0

HANA XS JS - Web service call error

Dec 09, 2016 at 08:20 PM

2.6k

avatar image
Former Member

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);
}
10 |10000 characters needed characters left 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

0
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.

0

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

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Dec 15, 2016 at 12:15 PM
0

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.


req.png (58.7 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank Mr. Hem. It worked. Apparently there was a problem in the XS trust connection.

1
Thomas Jung
Dec 12, 2016 at 12:28 PM
0

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.

Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Thomas, Yes useSSL is false because I did not establish trust in between HCI DS and HCP instance - no trust store configured.

Actually the request is being sent now by XS after using proxy.

host = "hcids.ap1.hana.ondemand.com";
port = 80; 
pathPrefix = "/DSoD/webservices";
description = "DS On Demand";
useSSL = false;
useProxy = true;
proxyHost ="proxy";
proxyPort = 8080;
authType = none;
timeout = 3000;

The above works : HCP AP DC apparently uses a proxy while it is not mentioned in the docs.But now the problem is that im getting the below error.

HttpClient.getResponse: Can't get the response from the server: internal error occurred "Connection to hcids.ap1.hana.ondemand.com lost while reading response."

So does this mean that HANA is not able to receive the response? I was not able to find any help in SAP blogs on this.

0
Former Member
Former Member

Hello Vyas,

It would be great if you could tell me how you resolved this issue I got the same response here

0
Former Member

Hi Thomas Jung,

i have created a xsjs service with a POST request and a Destination Service as well.

The destination configuration is as attached in the below image.capture.png

Also SSL is enabled and certificate has been imported to TRUST STORE , but whenever I am running the xsjsservice I am getting the below error :-

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

Please note I am using Hana trial account. Is that a problem. I am also getting same error when the destination is an http one, instead of https and authentication =none

Please help.

Regards.

Hirak Bhowmick

capture.png (15.8 kB)
0
Former Member

Hello Hirak, How did you enable the truststore here It would be good if you could tell me how you resolved the issues

0
Former Member
Former Member

you need to have Truststoreadminstrator role added to your userid

0