WSDL to Java                                                                                
•        The second task we will look at is how to create a client interface.  
•        A client can be generated using the WSDL file created by the Axis toolkit.  
•        To create a client we will follow a three step process.
1.        We will save the wsdl file to a local directory.
2.        Use the WSDL Engine which is called WSDL2Java in the Axis toolkit to generate client side stubs.
3.        Write a simple Java application that uses the stubs to invoke the web service.


•        To save the WSDL file to the local machine simply use the browser’s “File -> Save As” menu option.
-        The client will not have access to the MagicEightBall code, this WSDL file is the only thing shared
between client and server.
•        The next step is to run a tool provided by Axis called WSDL2Java.
-        All the detail on how to run this tool won’t be covered in the lecture.  WSDL2Java is described in more
detail in the WSDL chapter and in the lab.
-        The WSDL2Java tool is a Java program whose full name is org.apache.axis.wsdl.WSDL2Java.
-        After running the WSDL2Java tool you should be able to find four classes created by the tool:
MagicEightBallServiceLocator, MagicEightBallService, MagicEightBallSoapBindingStub and MagicEightBall.

•        The client you write can now use the classes created by WSDL2Java instead of creating an XML
payload by hand.
-        The client program is below.
public class Application {
 public static void main(String [] args) throws Exception
 {
         MagicEightBallService locator =
                 new MagicEightBallServiceLocator();
         MagicEightBall service = locator.getMagicEightBall();

         String ret = service.tellFortune("How you doing?");

         System.out.println("Answer: " + ret);
 }
}

-        The output from this run might be something like the following.
Answer: Hazy
WSDL to Java
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
Services