Consuming Web Services

Java and XML Binding

Hiding xml related code away from Java developers makes it easier to use web services.

With a little of bit work, you can hide away the XML and call the web service operation as if it was a local method. The arguments and return types of the methods will then be plain java instances. The grunt work turns into populating a java instance instead of XML DOM objects. The binder will automatically serialize and deserialize between XML and Java instances.

Steps for consuming a web service

I've used a couple of clients and the steps to consuming are roughly the same:

Obtain the wsdl

This should be given to you from the party you are integrating with. It is an web service description file in XML file format. It should tell what the available operations (methods) you can call, with the expected arguments and return types. The arguments and return types are defined in xsd format (if you are lucky.

Generate the bindings

Convert each argument and return types into Java classes that you can program against.

Setup the service instance (via Spring)

Abstract away all the web service and remoting code so you can program easier.

Published: Saturday, 20 January 2007