Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
One of the operations in Google's webservice API is making a spelling suggestion.
The service is described in this XML file, a stripped version, platform-neutral.
Web Services Description Language
The request parameters. The input message.
And the response value. The output message.
The call is translated...
into a SOAP-envelope (XML) and posted as HTTP body...
to this location, specified as endpoint in WSDL.
Likewise, the HTTP response contains an XML body,...
that is translated to a Java type, in this case, just a String.
SOAP, Simple Object Access Protocol. ( note: Object? What object? Nothing OO-like, anyway )
The classes used have been generated from the WSDL...
by Apache Axis's WSDL2Java tool. The image below shows how to do that using Eclipse 3.2 with WTP 1.5, containing the Axis libraries needed, like axis.jar. These are added to the project's build path by the wizard.
( If you want the client itself to be a web-application instead of a standalone, you'll have to start with a Dynamic Web Project. )
Web service providers publish their WSDL, so you can generate Java classes easily.
As you can see, SOAP brings A LOT OF OVERHEAD. (And this is just about character data, don't even think about binary data) If you don't need the XML interoperability that webservices offer, RMI / IIOP / CORBA, regular servlets or maybe even plain old socket-connection code can be much more efficient and better for performance (All depending on the need for and kind of interoperation ).
A development that is worth keeping an eye on is REST, as an alternative to SOAP. Used by Amazon and Ebay and a similar approach with Google's GData.
This lesson shows a Java client calling upon a Google service, but other clients can use that same service and be coded in PHP, VB, C++ etc. A client only needs a connection to the net and a SOAP-translation mechanism.
You can download Google's WSDL as part of their SOAP-kit and get your own key by visiting the link below the Essence box.
If you use Eclipse with WTP, there's a TCP/IP monitor that you can use to inspect what is actually transferred to and fro. You can find it here : Window, Preferences, Run/Debug, TCP/IP Monitor. See the picture below. DON'T FORGET TO STOP IT, when you're done.
You'll have to adapt one of the generated classes as shown.
( As an alternative you could use this class : org.apache.axis.utils.tcpmon, in axis.jar .)
Actually, CORBA / IIOP ( Internet Inter-Orb Protocol ) have been around since 9 years before SOAP, as a standard developed by the industry-wide ( well almost, guess who's missing ) OMG group, for heavy-duty, inter-process, platform-neutral communication, and is therefore much more advanced, mature, stable.( IIOP is used for RMI / EJB. ) You don't read much about it in the press, because it's just doing its job on lots of places, so no excitement there.
WSDL complexTypes describe data types (record-like and arrays) that are to be used as parameters or return values. (unused in this lesson)
Axis2 supports MTOM, to more efficiently transfer binary data.