Considerations                                                                                
•        Web Services is currently evolving.  Although widely accepted, deployed, and embraced some standards
are still being created.
-        There are few key standards producing organizations involved, and some standards are still being
questioned and challenged.
-        Although still emerging, many companies (large and small) have made web service creation a standard
for their organization.
•        The work on Web services is not done yet.  The API’s to make SOAP extensions to existing Web
servers are here, but they continue to evolve.
-        Microsoft has created Visual Studio .Net, a common tool for creating web services.
-        Apache provides the Axis toolkit for creating and consuming web services.
-        Commercial vendors like Systinet provide rich soap toolkits.
-        Sun, through the JCP (Java community process), has defined JAXM and JAXRPC as standard
definitions of API’S.  Axis is an implementation of JAXRPC.
-        Java proponent companies like IBM (and many others) are creating Java tools for implementing Web
Services.  Many are based on Axis.
-        The specifications are still evolving and existing implementations are still changing and defining required
services (routing and transactions among others).

Axis                                                                                                
•        To get started, we will create a simple Axis based web service.
-        We will create a simple prognostication web service called “MagicEightBall”.
-        For this to work, you will need to install Axis.  The procedure to complete that work will be presented
in the lab, or you can get more information from http://www.apache.org.
-        The Client program can generate Stubs to call the JAX-RPC runtime, or work with a more dynamic Call
class to invoke the web service.
-        When things fail, or when designing a system, it is best to have a good understanding of the SOAP
elements.
Magic Eight Ball Example                                                        
•        There are several ways to create a Web service using Axis.  For the first example we will create the
simplest type.
-        The first way we cover is not very flexible, so it is rarely used in production environments.
-        It will provide you the chance to install Axis and test that it is running correctly.
-        After you have it up and running it will take more effort to create a client program to test this web
service.  We will need to become proficient at creating tests for more complex services for continuing labs.
•        In two simple steps we can create a web service.
1.        Make an implementation of the service you wish to provide. (MagicEightBall.java)
2.        Save this java file to an Axis enabled web application with the .jws extension.

•        Step 1: Create MagicEightBall.java
-        Don’t include a package statement for this code, similar to a JSP.
-        The following class has one method that returns a string picked randomly from an array of strings.
public class MagicEightBall{

public String[] answers =
{ "Future Uncertain", "Yes", "No", "Hazy",
    "Ask again later", "Definitely"};

public String tellFortune(String s) {
//Get random number
int randNum = (int)(Math.random() * answers.length);

//Return a response out of answers using number
return new String(answers[randNum]);
}
}


•        Step 2: Copy it to a web application that has Axis installed
-        Simply save the MagicEightBall.java to the root directory of a web application that has Axis installed.
-        Change the extension from .java to .jws (java web service).
-        If Axis is properly installed, you have a web service, and you are done.

•        Although this seems too simple, it actually works.  To test it you can visit the jws page using a browser.
-        Similar to jsp the url of the site should be straight forward to figure out.
-        For this example (and all the labs) we will use the web application Axis.
-        When you visit the jws you should see the following page.



•        This doesn’t guarantee success.  Click on the “Click to see the WSDL” link and you should see the
WSDL definition.
Web Services Example
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