Skip to Content
avatar image
Former Member

How to call an internal HCP servlet from an XSJS service (Service to Service call)

Dear all,

On HCP, I have created a servlet to send email with an external email account.

Now, I would like to call this service from an XSJS service using the HTTP outbound API but I am struggling to make it working.

First of all, when I test my servlet from Postman, it works as expected without authentication or specific certificat...

But, then when I call this service from my XSJS service, I am not getting any response and actually, I am getting an HTTP code 302 as return code. Do you have any idea why ?

Here is the content of my http destination:

description = "eMail";
host = "";
port = 443;
proxyType = http;
proxyHost = "proxy";
proxyPort = 8080;
authType = none;
useSSL = true;
sslHostCheck = false;

For the port, I tried 443 and 8443 without success

Here is my XSJS code:

var dest = $.net.http.readDestination("", "servlet_mail");
var client = new $.net.http.Client();
//var req = new $.net.http.Request($.net.http.POST, "/mail");
var req = new $.web.WebRequest($.net.http.POST, "/mail");

//req.headers.set("host", "");  
req.headers.set("Content-Type", "application/json;charset=UTF-8");

client.request(req, dest); 
var response = client.getResponse(); 

On the XS admin side, I created a new Trust Store and uploaded the certificate that I have downloaded from my servlet page including the certificate for the domain Here, I am not sure if this is the right was to do it...

Anyway, after a lot of different tries, I am still getting this error 302. Any idea why? Am I using the right authentication mode, port, hostname ?

Is the keystore really needed when calling internal application in HCP ? What is the right process ?

Thanks in advance for your help !

Best regards,


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 26, 2017 at 10:08 PM

    Yes, I have found :)

    Actually, the service URL was incomplete. So, using the full URL including the servlet class name helped

    var req = new $.web.WebRequest($.net.http.POST, "/mail/ServletMail");

    ServletMail is my Servlet's name. In the associated web.xml, there is a servlet mapping pattern /mail pointing to this class and this is what it was causing the HTTP 302 "error".

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 20, 2017 at 01:33 PM

    Have you found any solution?

    Add comment
    10|10000 characters needed characters exceeded