O'Reilly logo

Java SOA Cookbook by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Client Proxy

Problem

You are tired of doing all of this work by hand to create your SOAP invocation with SAAJ. You want to have Java generate everything necessary for you to invoke a service based only on its WSDL.

Solution

Use the wsimport tool to generate the necessary client-side stubs and invoke them as you would a regular Java object.

Discussion

When you are new to web services the whole enterprise can be very daunting. This discussion will walk you through the use of the wsimport tool from a client developer’s perspective. It will touch on schema, JAXB, and how the parts hook up together under the hood so that you will have enough of a foundation going forward to know which items you need to concern yourself with and what gets taken care of for you.

The wsimport tool will read the WSDL of a deployed web service and generate the Java objects necessary to invoke it, including a class that extends javax.xml.ws.Service, which provides the client view of a web service. This can be a confusing concept because we tend to think of the service as being located on the server. But a service instance acts as a factory to create proxies that allow you to invoke a web service as if it was local. These proxies are sometimes referred to as SEI (Service Endpoint Interface) objects.

The tool generates portable artifacts that use only standard Java means. It will automatically call on JAXB to create value types that map Java to XML tand the result can be used to perform web services operations. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required