Developing WebServices using JDK6/JAX-WS is simple. Is it true?

In many articles, blogs we can see how to develop WebServices using with JDK6’s JAX-WS in-built support in just 5 minutes. We can simply write a POJO and annotate it with @WebService, publish it with Endpoint.publish(…) and you can see the generated wsdl by pointing your browser to http://localhost:8080/JAXWS/helloService?wsdl. Immediately we can write a client and call helloPort.sayHello(“siva”) and you will get “Hello Siva!!!” response from your HelloWebService. In the first look it feels like developing web services is very simple using JDK6’s in-built JAX-WS support. With that confidence immediately I thought of writing a bit more complex WebService and

Continue reading »

Deploying JAX-WS WebService on Tomcat-6

Now we are going to see how to deploy JAX-WS WebService on Tomcat Server.We are going to deploy The AuthenticationService developed in http://sivalabs.blogspot.com/2011/09/developing-webservices-using-jax-ws.html on apache-tomcat-6.0.32. To deploy our AuthenticationService we need to add the following configuration. 1.web.xml <web-app> <listener> <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class> </listener> <servlet> <servlet-name>authenticationService</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>authenticationService</servlet-name> <url-pattern>/services/AuthenticationService</url-pattern> </servlet-mapping></web-app> 2. Create a new file WEB-INF/sun-jax-ws.xml <?xml version="1.0" encoding="UTF-8"?><endpoints  xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"  version="2.0">    <endpoint      name="AuthenticationService"      implementation="com.sivalabs.caas.services.AuthenticationServiceImpl"      url-pattern="/services/AuthenticationService"/>      </endpoints> 3. Download the JAX-WS Reference Implementation from http://jax-ws.java.net/Copy all the jar files from jaxws-ri/lib folder to WEB-INF/lib. Now deploy the application on Tomcat server.You don’t need to publish the Service by our-self as we did using EndpointPublisher.Once the tomcat is up and running

Continue reading »

Developing WebServices using JAX-WS

Let us assume an enterprise is maintaining user authentication details in a centralized system. We need to create an AuthenticationService which will take credentials, validate them and return the status. The rest of the applications will use the AuthenticationService to authenticate the Users. Create AuthenticationService interface as follows: package com.sivalabs.caas.services;import javax.jws.WebService;import com.sivalabs.caas.domain.AuthenticationStatus;import com.sivalabs.caas.domain.Credentials;import com.sivalabs.caas.exceptions.AuthenticationServiceException;@WebServicepublic interface AuthenticationService{public AuthenticationStatus authenticate(Credentials credentials) throws AuthenticationServiceException;} package com.sivalabs.caas.domain;/** * @author siva * */public class Credentials { private String userName; private String password; public Credentials() { } public Credentials(String userName, String password) { super(); this.userName = userName; this.password = password; } //setters and getters } package

Continue reading »