tags:

views:

51

answers:

1

I have a restful web service running and that is a password protected application. I am using Client and WebResource in my java code to call the service. But when I am calling, I get the null principle error on the server side.

Can somebody please help me how to pass the username and password in my client class.

+2  A: 

You don't post any code, and you don't say how your service is password protected, so there's not much specific help that anyone can give.

In general, if you've enabled authentication on your server, then the server will challenge any request that does not contain a username/password (using a 401 status code). To avoid this challenge, you must provide those credentials in your request. Digest authentication is a better choice than Basic authentication, however you have to consider whether the entire message should be encrypted with SSL.

There are, of course, other ways to provide authentication to a RESTful service, such as access tokens.

kdgregory