cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a SAP web service from Java Servlet

Former Member
0 Kudos

I'm developing a Java Servlet that makes some calls to a Web Service (In SAP).

Before trying this calls on my servlet I did it in a Java standalone class and it worked just fine.


Nevertheless, when I move my code to a servlet (hosted on my localhost Glassfish server) it fails. Sap gives me the 401 HTTP error (Unable to authenticate).


Why does it work from a standalone class and not from the servlet?

Could it be that there's some configuration to be done in the SAP web service to allow it to accept requests from web servers?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

May be this is a Glassfish problem.

GlassFish will also send response headers like Server and X-Powered-By. See the following example from a 3.1.2:

---------

Server     GlassFish Server Open Source Edition 3.1.2

X-Powered-By     Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2 Java/Sun Microsystems Inc./1.6)

---------

Try to disable XPowered By in the HTTP tab for your http-listener-x in the Network Config.

May be you could put a Location header in 401 HTTP response but you would have to tell your client what to do with it. I found same problem at Java servlet redirect with status 401 issue

I hope this answeres your question.