WSDL Invocation Tools, Part I - Page 4
April 3, 2002
Given the WSDL file in Example
6-1, you could manually create a SOAP client to invoke the service. A
better alternative is to automatically invoke the
service via a WSDL invocation tool. (See Figure
6-4.)
Figure 6-4. WSDL invocation tools
|
|
Many WSDL invocation tools already exist. This section provides
a brief overview of three invocation tools.
GLUE
The Mind Electric provides a complete web service platform
called GLUE (available at http://www.themindelectric.com/).
The platform itself provides extensive support for SOAP, WSDL, and UDDI. Some
of its advanced functionality, including support for complex data types, will
be explored later in this chapter.
For now, you can try out the GLUE invoke command-line tool. Here is the command-line usage:
usage: invoke URL method arg1 arg2 arg3...
For example, to invoke the HelloService, make sure that your
Apache Tomcat server is running, and place the HelloService.wsdl file within a publicly available
directory. Then, issue the following command:
invoke http://localhost:8080/wsdl/HelloService.wsdl sayHello World
Once invoked, GLUE will immediately download the specified WSDL
file, invoke the sayHello method, and pass World as a parameter. GLUE will then automatically
display the server response:
Output: result = Hello, World!
That's all there is to it!
GLUE also supports an excellent logging facility that enables
you to easily view all SOAP messages. To activate the logging facility, set
the electric.logging system property. The easiest
option is to modify the invoke.bat file. The original
file looks like this:
call java electric.glue.tools.Invoke %1 %2 %3 %4 %5 %6 %7 %8 %9
Modify the file to include the logging property via the -D option to the Java interpreter:
call java -Delectric.logging="SOAP" electric.glue.tools.Invoke %1 %2 %3 %4
%5 %6 %7 %8 %9
When you invoke the HelloService, GLUE now generates the
following output: LOG.SOAP: request to http://207.237.201.187:8080/soap/servlet/rpcrouter
<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/soap/
envelope/' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
<soap:Body>
<n:sayHello xmlns:n='urn:examples:helloservice'>
<firstName xsi:type='xsd:string'>World</firstName>
</n:sayHello>
</soap:Body>
</soap:Envelope>
LOG.SOAP: response from http://207.237.201.187:8080/soap/servlet/rpcrouter
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/1999/XMLSchema'>
<SOAP-ENV:Body>
<ns1:sayHelloResponse
xmlns:ns1='urn:examples:helloservice'
SOAP-ENV:encodingStyle=
'http://schemas.xmlsoap.org/soap/encoding/'>
<return xsi:type='xsd:string'>Hello, World!</return>
</ns1:sayHelloResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
result = Hello, World!
To view additional HTTP information, just set electric.logging to SOAP,HTTP.
SOAP::Lite for Perl
SOAP::Lite for Perl, written by Paul Kulchenko, also provides
limited support for WSDL. The package is available at http://www.soaplite.com.
Example
6-2 provides a complete Perl program for invoking the HelloService.
Example 6-2: Hello_Service.pl
use SOAP::Lite;
print "Connecting to Hello Service...\n";
print SOAP::Lite
-> service('http://localhost:8080/wsdl/HelloService.wsdl')
-> sayHello ('World');
The program generates the following output:
Connecting to Hello Service...
Hello, World!
IBM Web Services Invocation Framework (WSIF)
Finally, IBM has recently released WSIF. The package is
available at http://www.alphaworks.ibm.com/tech/wsif.
Much like GLUE, WSIF provides a simple command-line option for
automatically invoking WSDL services. For example, the following command:
java clients.DynamicInvoker http://localhost:8080/wsdl/HelloService.wsdl
sayHello World
generates the following output:
Reading WSDL document from 'http://localhost:8080/wsdl/HelloService.wsdl'
Preparing WSIF dynamic invocation
Executing operation sayHello
Result:
greeting=Hello, World!
Done!
Basic WSDL Example: HelloService.wsdl (cont.) - Page 3
Web Services Essentials
Basic WSDL Example: XMethods eBay Price Watcher Service - Page 5
|