Chapter 6. Developing a JAX-WS 2.2 Web Service

Java API for XML-based Web Services, known as JAX-WS (http://jcp.org/aboutJava/communityprocess/mrel/jsr224/index2.html), is a W3C standards-based technology for communicating between services and clients using XML over the HTTP protocol. Some of the W3C standards that JAX-WS Web Services support are HTTP (http://www.w3.org/Protocols/), SOAP (http://www.w3.org/TR/soap/), and Web Service Description Language (WSDL) (http://www.w3.org/TR/wsdl). JAX-WS is a platform-independent standard; JAX-WS Web Services may communicate with non-Java clients, for example a .NET client, and a JAX-WS client may communicate with non-Java Web Services, a .NET Web Service for example. JAX-WS makes use of XML in the following artifacts:

  • The WSDL is an XML document that describes network services as a set of endpoints operating on messages; an endpoint being a URL location representing a web service
  • A client and a web service communicate using SOAP messages, which are in the XML format

A JAX-WS web service consists of the following components:

  • A non-final, non-abstract Java class that is annotated with javax.jws.WebService annotation. The web service endpoints, the Java class consists of business methods. A web service client creates a proxy of the web service to invoke its methods (operations). The web service optionally returns a response. The web service request and response are SOAP messages over HTTP.
  • An optional Java interface that defines the methods implemented in the web service implementation class.

This chapter has the following sections:

  • Setting up the environment
  • Creating a Java EE web project
  • Creating a web descriptor
  • Creating a JAX-WS Web Service
  • Creating a web service client
  • Deploying the JAX-WS application with Maven
  • Running the JAX-WS application

Setting up the environment

We need to download and install the following software:

Set the environment variables, JAVA_HOME, JBOSS_HOME, and MAVEN_HOME. Add %JAVA_HOME%/bin, %MAVEN_HOME%/bin, and %JBOSS_HOME%/bin to the PATH environment variable.

Create a WildFly 8.1.0 runtime as discussed in Chapter 1, Getting Started with EJB 3.x.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset