on 03-15-2017 3:45 PM
Hi,
I'm calling a web service from XS Engine in my HCP Trial Account, but I get a socket error as follows please help.
Erro Message:
HttpClient.request: request failed: internal error occurred "Failed to send request to socket...rc = -1"
HttpDest
host = "geocoder.cit.api.here.com";
port = 80;
description = "HERE Geocoder";
useSSL = false;
pathPrefix = "/6.2/geocode.xml";
authType = none;
useProxy = false;
proxyHost = "proxy-trial";
proxyPort = 8080;
timeout = 3000;
XSJS File
var destination_package = "here";
var destination_name = "here";
var appid = "&<My App ID>";
var appcode = "&<my App Code>";
var gen = "&gen=8";
var address = "Walldorf Hasso-Plattner-Ring 7";
try {
var dest = $.net.http.readDestination(destination_package, destination_name);
var client = new $.net.http.Client();
var req = new $.web.WebRequest($.net.http.GET, "?searchtext=" + address + appid + appcode + gen);
client.request(req, dest);
var response = client.getResponse();
$.response.contentType = "application/json";
$.response.setBody(response.body.asString());
$.response.status = $.net.http.OK;
} catch (e) {
$.response.contentType = "text/plain";
$.response.setBody(e.message);
}
There are different errors in your xshttpdest and the xsjs file.
xshttpdest
xsjs
Following are the files for a working example (you just have to set the app_id and app_code values for your HERE project):
host = "geocoder.cit.api.here.com1";
port = 80;
description = "HERE Geocoder";
useSSL = false;
pathPrefix = "/6.2/geocode.xml";
authType = none;
useProxy = true;
proxyHost = "proxy-trial";
proxyPort = 8080;
timeout = 3000;
var destinationPackage = "here";
var destinationName = "here";
var appid = "<app_id value>";
var appcode = "<app_code value>";
var gen = "8";
var address = encodeURI("Walldorf Hasso-Plattner-Ring 7");
try {
var dest = $.net.http.readDestination(destinationPackage, destinationName);
var client = new $.net.http.Client();
var req = new $.net.http.Request($.net.http.GET, "?searchtext=" + address +
"&app_id=" + appid +
"&app_code=" + appcode +
"&gen=" + gen);
client.request(req, dest);
var response = client.getResponse();
$.response.contentType = "application/xml";
$.response.setBody(response.body.asString());
$.response.status = $.net.http.OK;
client.close();
} catch (e) {
$.response.contentType = "text/plain";
$.response.setBody(e.message);
}
Regards,
Florian
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 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.