简体   繁体   中英

Web service 401 Unauthorized error

I have created web service using c#. I consumed using c# client I got 401 Unauthorized error. So, I set the property UseDefaultCredentials = true.

Then I tried to access the web service using java client, I get again 401 Unauthorized error. I don't know how to use java client stubs. So, can someone point me in that direction.

I got these class files in Eclipse

DemoWebServ.java
DemoWebServLocator.java
DemoWebServSoap.java
DemoWebServSoapProxy.java
DemoWebServSoapStub.java

I need to access the web service by giving username and password by using above stubs

EDIT 1

on some googling i found that adding

    _call.setProperty(org.apache.axis.client.Call.USERNAME_PROPERTY, "USERNAME");
    _call.setProperty(org.apache.axis.client.Call.PASSWORD_PROPERTY, "PASSWORD");

will solve the issue but even after adding above statements in DemoWebServSoapStub.java. I have not been able to resolve the issue

Figured out the solution,

This happened because of the anonymous access security for website in IIS. I used the account I have on the windows server to set anonymous access uname/password. Then I used the same combination in

_call.setProperty(org.apache.axis.client.Call.USERNAME_PROPERTY, "USERNAME");
_call.setProperty(org.apache.axis.client.Call.PASSWORD_PROPERTY, "PASSWORD");

It worked. I dont know how secure it is :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM