cancel
Showing results for 
Search instead for 
Did you mean: 

How to authenticate a web service though java

Former Member
0 Kudos

Hello all,

I have created a DC of type Web Services and created a deployable proxy using a (*.wsdl) file. Now I using this proxy in a simple standalone java application.

When I call this webservice in my java code, it returns Invalid Response Code: (401) Unauthorized error.

Then I went to the Visual Admin Tool and set the authentication of the proxy as BASIC and typed the userid/password. It worked.

Now my issue is that I dont want to have this fixed userid/password on the server side. I want userid/password to be passed to the webservice dynamically from my java code without having to manually set them using the Visual Admin Tool.

How to achieve this ?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vikram

Please check the following links

http://help.sap.com/saphelp_nw04s/helpdata/en/bb/961f07328bc3448e0e570e6b3c650f/content.htm

and

[original link is broken]

and

https://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/1f3ac55d-0501-0010-e2ba-832279d7cae9 [original link is broken]

I hope it helps

Regards

Chen

Answers (1)

Answers (1)

Former Member
0 Kudos

Thnx Chetan.

Wat I was trying to achieve was quite basic. I have figured it out myself using this code.

I had to just set the user/password in the java code using the _setproperty methods of the port.

Eg:

port is an object of MI_OS_XXXX class of wsdl and is used to send the request to the web service.

In the java code add:

port._setProperty(MI_OS_XXXX .USERNAME_PROPERTY, login); // login is a string holding the userid

port._setProperty(MI_OS_XXXX .PASSWORD_PROPERTY, password);

And in Visual Admin Tool, set the Authentication of proxy to None and remove the username and password.