on 01-15-2017 8:26 PM
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 = "myservletXXXac000000.hana.ondemand.com";
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("courseducoeur.compagnon.services.anonymous", "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", "cdcmailac478bd45.hana.ondemand.com");
req.headers.set("Content-Type", "application/json;charset=UTF-8");
req.setBody(JSON.stringify(oData));
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 hana.ondemand.com. 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,
Nico.
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".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you found any solution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.