Skip to Content
0

Calling Service Layer from XS Application

Dec 11, 2017 at 05:37 PM

51

avatar image
Former Member

Hi,

I have situation where my client wants to update SAP entities via the XS Application. To allow this without invalidating the SAP data, I need to call the Service Layer (unless there is a better way)

I've looked for a similar answer but most of what I found appeared to be faults that I have corrected.

The error message is "{"error":"HttpClient.request: request failed: internal error occurred \"Failed to send request to socket...rc = -1\""}".

B1SL.xshttpdest is set up in trust manager

host = "servicelayer.url.com";
port = 50000;
pathPrefix = "/b1s/v1/";
authType = none;
useSSL = true;
timeout = 0;

My test.xsjs service:

function respond(obj){
    $.response.contentType = "application/json";
    $.response.setBody(JSON.stringify(obj));
    $.response.status = $.net.http.OK;
}
var client = new $.net.http.Client();
var destination = $.net.http.readDestination("b1s.v1.Libs", "B1SL");
var req = new $.web.WebRequest($.net.http.GET, 'Items');
try{
    client.request(req, destination);
    var response = client.getResponse();
    respond(response);
}catch(ex){
    respond({error:ex.message});
}

Where have I gone wrong?

Ta

10 |10000 characters needed characters left characters exceeded
Former Member

Hey Daniel,

Did you ever get this resolved? I get the same error in a similar scenario.

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

0 Answers