Search code examples
javaweb-servicesjax-wsbasic-authentication

simple jax-ws-webservice with basic authentication


I have a simple WSDL for a webservice. With wsimport I generated the java wrappers. And I have implemented the generated interface in a class "MyService". Then I publish this webservice with the built-in features of Java6:

MyService myService = new MyService();
Endpoint endpoint = Endpoint.publish("http://localhost:80/servicetest/services/MyServiceINSoap", myService);

When I let this code run, everything works perfect - I am able to connect to the service with a soapclient and can execute the methods.

Now I want the built-in webserver of the javavm to use basic authentication - so the client has to provide an userid and a password. How do I accomplish this? Is this possible? Or do I need an application server (tomcat, jboss, whatever...)?

I have searched for some time but only found solutions for webservice which are hosted in an application server.

Many thanks in advance!

erwrock


Solution

  • Found a solution here:

    https://today.java.net/pub/a/today/2007/07/03/jax-ws-web-services-without-ee-containers.html

    after hours of trial-and-error finally the right searchwords in google :)