Book Image

Java 7 JAX-WS Web Services

By : Deepak Vohra
Book Image

Java 7 JAX-WS Web Services

By: Deepak Vohra

Overview of this book

<p>Web services are applications that use open, XML-based standards and transport protocols to exchange data with clients. <br /><br />In the book Developing a JAX-WS Web Service using the wsimport clientjar Option, we shall create a JAX-WS web service with Java 7. We shall discuss the new clientjar option in the wsimport tool or the wsimport ant task which is used to generate JAX-WS portable artifacts from a service wsdl. Subsequently, we use the web service artifacts to invoke the web service from a web service client.</p>
Table of Contents (8 chapters)

Creating a client class


Create a client Java class hellowsclient.HelloWSClient. In the Java client application, create an instance of the HelloWSService service:

hellows.HelloWSService service=new HelloWSService();

The Service class will be created during the build, which is explained later. Obtain a proxy to the service from the service using the getHelloWSPort() method:

hellows.HelloWS port = service.getHelloWSPort();

Invoke the hello(String) method of the service using the service proxy:

String result = port.hello("John Smith.");

Output the result of the web service method invocation. The Java client class is listed as follows:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package hellowsclient;
/**
*
* @author dvohra
*/
import hellows.*;
public class HelloWSClient {
/**
* @param args
*/
public static void main(String[] args) {
hellows.HelloWSService service = new hellows.HelloWSService();
hellows.HelloWS port = service.getHelloWSPort...