Authoring the Service Invocation Request
After parsing the complete WSDL file, load it into a WSDLClient object. As shown in Figure 4, each <operation> becomes an object of the Operation class and each <message> element becomes an object of the Parameter class. The Operation class is also capable of coordinating with SOAP and HTTP classes to send method invocation calls.
| |
 |
Figure 6. One object of the WSDLClient holds several Operation objects. Each Operation object holds input and output Parameter objects.
|
Take a look at the following three methods of the Operation class:
- SetValue()
- Send()
- GetBody()
These three methods provide an easy way of authoring SOAP service invocation requests for any Operation object. Once the WSDL files are parsed and their data structures (which are essentially Operation objects that contain Parameter objects) are loaded, call the setValue() method of the Operation class to provide parameter values. To send the SOAP method invocation request, call the send() method of the Operation class. Internally, the Send() method uses the getBody() method to author the SOAP Body. It then sends the request, waits for the SOAP response, and returns it when received. There's no need to worry about SOAP request authoring because the WSDL client hides SOAP-related functionality from its users.
Using the Applet Container
Listing 5 is an applet-based container for the WSDL client. It represents the GUI shown in Figure 3.
To test this applet:
- Type the URL of the WSDL file in the text box labeled "Enter WSDL file URL". For example type http://www.mywebservice.com/mywsdl.wsdl.
- Type the SOAP server address in text box labeled "Enter SOAP server URL". For example type http://www.mywebservice.com/soap. This information may also be contained within the WSDL file (within the SOAP:address element). In that case, entering the full URL is optional.
- Press the "Download WSDL" button. This populates the method list with service method names.
- Select a method from the methods list for making a call. The parameters required are shown in the parameter window.
- Enter the parameter values in the parameter window.
- Press the "Invoke Method" button. This executes the call. The server response of your call is shown in the output window.
Bilal Siddiqui is an Electronics Engineer, an XML consultant, and the co-founder of WaxSys, a company focused on simplifying e-Business. He is a technology evangelist and frequently-published technical author. You can contact Bilal at bsiddiqui@waxsys.com.