You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by nm...@apache.org on 2002/12/13 23:59:56 UTC

cvs commit: xml-axis-wsif/java/samples/ejb/service/deploy/jboss addressbook.jar ejb-jar.xml jboss.xml

nmukhi      2002/12/13 14:59:56

  Modified:    java/samples/ejb README.html
  Added:       java/samples/ejb AddressBook.wsdl
               java/samples/ejb/client/dynamic README.html Run.java
               java/samples/ejb/client/jboss_setup jboss.bat
               java/samples/ejb/client/stub README.html Run.java
               java/samples/ejb/service AddressBookSession.java
                        AddressBookSessionBean.java
                        AddressBookSessionHome.java README.html
               java/samples/ejb/service/addressbook/wsifservice
                        AddressBook.java
               java/samples/ejb/service/addressbook/wsiftypes Address.java
                        Phone.java
               java/samples/ejb/service/deploy/jboss addressbook.jar
                        ejb-jar.xml jboss.xml
  Log:
  Completed EJB sample + docs + instructions on running with JBoss
  
  Revision  Changes    Path
  1.2       +22 -0     xml-axis-wsif/java/samples/ejb/README.html
  
  Index: README.html
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/ejb/README.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- README.html	11 Dec 2002 16:00:48 -0000	1.1
  +++ README.html	13 Dec 2002 22:59:55 -0000	1.2
  @@ -0,0 +1,22 @@
  +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
  +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  +<meta name="Author" content="Nirmal Mukhi">
  +<meta http-equiv="Content-Style-Type" content="text/css">
  +<title>Web Services Invocation Framework: Samples</title>
  +<link rel="stylesheet" href="wsif.css" type="text/css"></head>
  +
  +<body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2" marginwidth="2" marginheight="2">
  +
  +<h1>
  +Web Services Invocation Framework:<br>
  +EJB Sample</h1>
  +<p>This sample aims to demonstrate the invocation of an EJB through WSIF's API. This means that an EJB is exposed as a first class WSDL-described service using the <a href="../../doc/wsdl_extensions/ejb_extension.html">EJB binding extensions</a> defined in WSIF.</p>
  +<p>In this particular sample, we describe an AddressBook service, a common example in various Web services toolkits. For those unfamilar with it, this service offers a port type with three operations. Two of the operations add an entry to the address book, using slightly different styles for providing input information. The third operation queries the address book with a name. The service uses complex schema types for representing an address and a phone number.</p>
  +<p>The abstract functionality is tied to an EJB binding that describes how a stateful session bean supports the abstract port type defined. It is worth emphasizing that this isn't a standard WSDL binding, instead it exploits WSDL's extensibility to describe how to access the abstract functionality when it is deployed and available on an EJB. You will notice that the <tt>&lt;ejb:address&gt;</tt> element in the <a href="AddressBook.wsdl">AddressBook WSDL</a> refers to an initial context factory that gets used by WSIF's EJB provider. The classpath specified here is vendor specific and will need to be changed depending on your particular deployment.</p>
  +<p>The <a href="AddressBook.wsdl">WSDL file</a> is in this sample directory; this has the EJB binding.</p>
  +<p><a href="service/README.html">Here's</a> how this service is implemented. We also describe how to deploy the EJB on a J2EE platform of your choice.</p>
  +<p><a href="client/dynamic/README.html">Here's</a> how to invoke this service dynamically using WSIF's dynamic invocation interface (DII).</p>
  +<p><a href="client/stub/README.html">Here's</a> how to invoke this service by first generating the stub interface and using this directly through WSIF's dynamic proxy, thus hiding all WSIF specifics from the client code. Note that the stub interface used is the the service interface as defined by the JAX-RPC specification.</p>
  +<p>Deployment of an EJB as well as acessing and using it is vendor-specific. We have made it particularly simple to run this sample if you use <a href="http://www.jboss.org">JBoss</a> as your application server, but have also provided enough documentation so that it should not be hard to run this sample in a different environment.
  +<hr width="100%">
  +</body></html>
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/AddressBook.wsdl
  
  Index: AddressBook.wsdl
  ===================================================================
  <?xml version="1.0" ?>
  
  <definitions targetNamespace="http://wsifservice.addressbook/"
               xmlns:tns="http://wsifservice.addressbook/"
               xmlns:typens="http://wsiftypes.addressbook.service.ejb/"
               xmlns:xsd="http://www.w3.org/1999/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
               xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/"
               xmlns:ejb="http://schemas.xmlsoap.org/wsdl/ejb/"
               xmlns="http://schemas.xmlsoap.org/wsdl/">
  
    <!-- type defs -->
    <types>
      <xsd:schema
        targetNamespace="http://wsiftypes.addressbook.service.ejb/"
                  xmlns:xsd="http://www.w3.org/1999/XMLSchema">
        <xsd:complexType name="phone">
          <xsd:sequence>
            <xsd:element name="areaCode" type="xsd:int"/>
            <xsd:element name="exchange" type="xsd:string"/>
            <xsd:element name="number" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
  
        <xsd:complexType name="address">
          <xsd:sequence>
            <xsd:element name="streetNum" type="xsd:int"/>
            <xsd:element name="streetName" type="xsd:string"/>
            <xsd:element name="city" type="xsd:string"/>
            <xsd:element name="state" type="xsd:string"/>
            <xsd:element name="zip" type="xsd:int"/>
            <xsd:element name="phoneNumber" type="typens:phone"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:schema>
    </types>
  
    <!-- message declns -->
    <message name="AddEntryWholeNameRequestMessage">
      <part name="name" type="xsd:string"/>
      <part name="address" type="typens:address"/>
    </message>
  
    <message name="AddEntryFirstAndLastNamesRequestMessage">
      <part name="firstName" type="xsd:string"/>
      <part name="lastName" type="xsd:string"/>
      <part name="address" type="typens:address"/>
    </message>
  
    <message name="GetAddressFromNameRequestMessage">
      <part name="name" type="xsd:string"/>
    </message>
  
    <message name="GetAddressFromNameResponseMessage">
      <part name="address" type="typens:address"/>
    </message>
  
    <!-- port type declns -->
    <portType name="AddressBook">
      <operation name="addEntry">
        <input name="AddEntryWholeNameRequest" message="tns:AddEntryWholeNameRequestMessage"/>
      </operation>
      <operation name="addEntry">
        <input name="AddEntryFirstAndLastNamesRequest" message="tns:AddEntryFirstAndLastNamesRequestMessage"/>
      </operation>
      <operation name="getAddressFromName">
        <input name="GetAddressFromNameRequest" message="tns:GetAddressFromNameRequestMessage"/>
        <output name="GetAddressFromNameResponse" message="tns:GetAddressFromNameResponseMessage"/>
      </operation>
    </portType>
  
    <!-- binding declns -->
    <binding name="EJBBinding" type="tns:AddressBook">
      <ejb:binding/>
      <format:typeMapping encoding="Java" style="Java">
        <format:typeMap typeName="typens:address" formatType="ejb.service.addressbook.wsiftypes.Address" />
        <format:typeMap typeName="xsd:string" formatType="java.lang.String" />
      </format:typeMapping>
      <operation name="addEntry">
        <ejb:operation
           methodName="addEntry"
           parameterOrder="name address"
           interface="remote" />
        <input name="AddEntryWholeNameRequest"/>
      </operation>
      <operation name="addEntry">
        <ejb:operation
           methodName="addEntry"
           parameterOrder="firstName lastName address"
           interface="remote" />
        <input name="AddEntryFirstAndLastNamesRequest"/>
      </operation>
      <operation name="getAddressFromName">
        <ejb:operation
           methodName="getAddressFromName"
           parameterOrder="name"
           interface="remote"
           returnPart="address" />
        <input name="GetAddressFromNameRequest"/>
        <output name="GetAddressFromNameResponse"/>
      </operation>
    </binding>
  
    <!-- service decln -->
    <service name="AddressBookService">
      <!-- JBoss specific EJB endpoint -->
      <port name="EJBPort" binding="tns:EJBBinding">
  	<ejb:address className="ejb.service.AddressBookSession"
  		     jndiName="ejb/service/AddressBook"
                       initialContextFactory="org.jnp.interfaces.NamingContextFactory"
  	             jndiProviderURL="localhost"/>
      </port>
    </service>
  
  </definitions>
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/client/dynamic/README.html
  
  Index: README.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Nirmal Mukhi">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title>Web Services Invocation Framework: Samples</title>
  <link rel="stylesheet" href="wsif.css" type="text/css"></head>
  
  <body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2" marginwidth="2" marginheight="2">
  
  <h2>
  Web Services Invocation Framework:<br>
  Invoking the EJB Sample using WSIF's dynamic invocation interface</h2>
  <p>First you need to <a href="../../../../doc/samples.html">set up the CLASSPATH in your environment</a>. Beyond the standard classpath setting, you also need to add the J2EE client jar files to your classpath. The set of J2EE client JARs is vendor specific; refer to the documentation in your application server on how to set up the environment for an EJB client, and add the JAR files specified. For JBoss users, we have included a script to set up the client environment. To run this script, make sure you are in your base WSIF directory (the one that contains the <tt>classpath.bat</tt> script. Set the variable <tt>JBOSS_HOME</tt> to point to your JBoss installation. From there, run the command <tt>samples\ejb\client\jboss_setup\jboss.bat</tt>. This sets up the entire client classpath required to run the sample using JBoss client JAR files.</p>
  <p>The <a href="../../AddressBook.wsdl">WSDL file</a> that describes the service and its EJB binding is vendor-specific in the <tt>&lt;ejb:address&gt;</tt> element. The <tt>initialContextFactory</tt>, <tt>jndiName</tt> and <tt>jndiProviderURL</tt> attributes will all depend on your specific deployment; refer to your application server documentation on how to write an EJB client to learn more about JNDI and related issues. Make sure these values are all correct before you try running the client.</p>
  <p>After you have set up your classpath, to invoke this sample using WSIF's DII, run the <tt>Run</tt> class located in this directory. This class will populate an addressbook with two names and then query each of them by invoking various operations supported by the service. To run this class, specify on the command line the location of the WSDL file for the service. For example, <br><tt>java ejb.clients.dynamic.Run samples/ejb/AddressBook.wsdl</tt></p>
  <p>Look at the code in the <tt>Run.java</tt> file in this directory to see how to use WSIF's DII yourself. Note that the <tt>DynamicInvoker</tt> class we used to <a href="../../../simplesoap/client/dynamic/README.html">invoke the simplesoap sample dynamically</a> cannot be used for this one since the <tt>DynamicInvoker</tt> as it stands now is limited to invocation of services using primitive schema types only.</p>
  <hr width="100%">
  </body></html>
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/client/dynamic/Run.java
  
  Index: Run.java
  ===================================================================
  package ejb.client.dynamic;
  
  import javax.xml.namespace.QName;
  
  import org.apache.wsif.WSIFMessage;
  import org.apache.wsif.WSIFException;
  import org.apache.wsif.WSIFOperation;
  import org.apache.wsif.WSIFPort;
  import org.apache.wsif.WSIFService;
  import org.apache.wsif.WSIFServiceFactory;
  
  import ejb.service.addressbook.wsiftypes.Address;
  import ejb.service.addressbook.wsiftypes.Phone;
  
  public class Run {
      private static void addFirstAddress(WSIFPort port) {
  	try {
  	    // create the operation
  	    // note that we have two operations with the same name, so we need to specify the
  	    // name of the input and output messages as well
  	    WSIFOperation operation = port.createOperation("addEntry","AddEntryWholeNameRequest",null);
  	    // create the input message associated with this operation
  	    WSIFMessage input = operation.createInputMessage();
  	    // populate the input message
  	    input.setObjectPart("name","John Smith");
  	    // create an address object to populate the input
  	    Address address = new Address();
  	    address.setStreetNum(25);
  	    address.setStreetName("Willow Road");
  	    address.setCity("MyTown");
  	    address.setState("PA");
  	    address.setZip(28382);
  	    Phone phone = new Phone();
  	    phone.setAreaCode(288);
  	    phone.setExchange("555");
  	    phone.setNumber("9891");
  	    address.setPhoneNumber(phone);
  	    input.setObjectPart("address",address);
  	    // do the invocation
  	    System.out.println("Adding address for John Smith...");
  	    operation.executeInputOnlyOperation(input);
  	} catch (WSIFException we) {
  	    System.out.println("Got exception from WSIF, details:");
  	    we.printStackTrace();
  	}
      }
  	
      private static void addSecondAddress(WSIFPort port) {
  	try {
  	    // create the operation
  	    // note that we have two operations with the same name, so we need to specify the
  	    // name of the input and output messages as well
  	    WSIFOperation operation = port.createOperation("addEntry","AddEntryFirstAndLastNamesRequest",null);
  	    // create the input message associated with this operation
  	    WSIFMessage input = operation.createInputMessage();
  	    // populate the input message
  	    input.setObjectPart("firstName","Jane");
  	    input.setObjectPart("lastName","White");
  	    // create an address object to populate the input
  	    Address address = new Address();
  	    address.setStreetNum(20);
  	    address.setStreetName("Peachtree Avenue");
  	    address.setCity("Atlanta");
  	    address.setState("GA");
  	    address.setZip(39892);
  	    Phone phone = new Phone();
  	    phone.setAreaCode(701);
  	    phone.setExchange("555");
  	    phone.setNumber("8721");
  	    address.setPhoneNumber(phone);
  	    input.setObjectPart("address",address);
  	    // do the invocation
  	    System.out.println("Adding address for Jane White...");
  	    operation.executeInputOnlyOperation(input);
  	} catch (WSIFException we) {
  	    System.out.println("Got exception from WSIF, details:");
  	    we.printStackTrace();
  	}
      }
  
      private static void queryAddresses(WSIFPort port) {
  	try {
  	    // create the operation
  	    WSIFOperation operation = port.createOperation("getAddressFromName");
  	    // create the input message associated with this operation
  	    WSIFMessage input = operation.createInputMessage();
  	    WSIFMessage output = operation.createOutputMessage();
  	    WSIFMessage fault = operation.createFaultMessage();
  	    // populate the input message
  	    input.setObjectPart("name","John Smith");
  	    // do the invocation
  	    System.out.println("Querying address for John Smith...");
  	    if (operation.executeRequestResponseOperation(input,output,fault)) {
  		// invocation succeeded
  		// extract the address from the output message
  		Address address = (Address) output.getObjectPart("address");
  		System.out.println("Service returned the following address:");
  		System.out.println(address.getStreetNum()+" "+address.getStreetName()+
  				   ", "+address.getCity()+" "+address.getState()+" "+
  				   address.getZip()+"; Phone: ("+
  				   address.getPhoneNumber().getAreaCode()+") "+
  				   address.getPhoneNumber().getExchange()+"-"+
  				   address.getPhoneNumber().getNumber());
  	    } else {
  		// invocation failed, check fault message
  	    }
  	    // create the operation
  	    operation = port.createOperation("getAddressFromName");
  	    // create the input message associated with this operation
  	    input = operation.createInputMessage();
  	    output = operation.createOutputMessage();
  	    fault = operation.createFaultMessage();
  	    // populate the input message
  	    input.setObjectPart("name","Jane White");
  	    // do the invocation
  	    System.out.println("Querying address for Jane White...");
  	    if (operation.executeRequestResponseOperation(input,output,fault)) {
  		// invocation succeeded
  		// extract the address from the output message
  		Address address = (Address) output.getObjectPart("address");
  		System.out.println("Service returned the following address:");
  		System.out.println(address.getStreetNum()+" "+address.getStreetName()+
  				   ", "+address.getCity()+" "+address.getState()+" "+
  				   address.getZip()+"; Phone: ("+
  				   address.getPhoneNumber().getAreaCode()+") "+
  				   address.getPhoneNumber().getExchange()+"-"+
  				   address.getPhoneNumber().getNumber());
  	    } else {
  		// invocation failed, check fault message
  	    }
  	} catch (WSIFException we) {
  	    System.out.println("Got exception from WSIF, details:");
  	    we.printStackTrace();
  	}
      }
  
      public static void main(String [] args) throws Exception {
  	if(args.length!=1) {
  	    System.out.println("Usage: java samples.java.client.dynamic.Run <wsdl location>");
  	    System.exit(1);
  	}
  	// create a service factory
          WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  	
  	WSIFService service = factory.getService(args[0], null,
  						 null, "http://wsifservice.addressbook/", 
  						 "AddressBook"); 
  	// map types
  	service.mapType(new QName("http://wsiftypes.addressbook/","Address"),
  			Class.forName("ejb.service.addressbook.wsiftypes.Address"));
  	service.mapType(new QName("http://wsiftypes.addressbook/","Phone"),
  			Class.forName("ejb.service.addressbook.wsiftypes.Phone"));
  
  	// get the port
  	WSIFPort port = service.getPort();
  	// add the first address
  	addFirstAddress(port);
  	// add the second address
  	addSecondAddress(port);
  	// query addresses
  	queryAddresses(port);
      }
  }
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/client/jboss_setup/jboss.bat
  
  Index: jboss.bat
  ===================================================================
  @echo off
  
  REM Written by Nirmal Mukhi and Alek Slominski
  REM Purpose of script: add JBoss client JARs to the classpath 
  REM so that WSIF EJB sample can be run using JBoss J2EE client jars
  
  REM check for JBoss home
  if "%JBOSS_HOME%" == "" goto jbosshomeerror
  set JBOSS_HOME=%JBOSS_HOME%
  
  REM setup classpath to run WSIF sample using JBoss EJB client JARs
  call classpath.bat quiet
  
  REM add to JBOss client JARs to classpath
  for %%i in (%JBOSS_HOME%\client\*.jar) do call lib\ant\lcp.bat %%i
  
  REM set the classpath
  set CLASSPATH=%LOCALCLASSPATH%
  
  echo %CLASSPATH%
  
  goto end
  
  :jbosshomeerror
  echo "ERROR: JBOSS_HOME not found in your environment."
  echo "Please, set the JBOSS_HOME variable in your environment to match the"
  echo "location of your JBoss installation."
  
  :end
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/client/stub/README.html
  
  Index: README.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Nirmal Mukhi">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title>Web Services Invocation Framework: Samples</title>
  <link rel="stylesheet" href="wsif.css" type="text/css"></head>
  
  <body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2" marginwidth="2" marginheight="2">
  
  <h2>
  Web Services Invocation Framework:<br>
  Invoking the EJB Sample through a high level stub interface</h2>
  <p>First you need to <a href="../../../../doc/samples.html">set up the CLASSPATH in your environment</a>. Beyond the standard classpath setting, you also need to add the J2EE client jar files to your classpath. The set of J2EE client JARs is vendor specific; refer to the documentation in your application server on how to set up the environment for an EJB client, and add the JAR files specified. For JBoss users, we have included a script to set up the client environment. To run this script, make sure you are in your base WSIF directory (the one that contains the <tt>classpath.bat</tt> script. Set the variable <tt>JBOSS_HOME</tt> to point to your JBoss installation. From there, run the command <tt>samples\ejb\client\jboss_setup\jboss.bat</tt>. This sets up the entire client classpath required to run the sample using JBoss client JAR files.</p>
  <p>The <a href="../../AddressBook.wsdl">WSDL file</a> that describes the service and its EJB binding is vendor-specific in the <tt>&lt;ejb:address&gt;</tt> element. The <tt>initialContextFactory</tt>, <tt>jndiName</tt> and <tt>jndiProviderURL</tt> attributes will all depend on your specific deployment; refer to your application server documentation on how to write an EJB client to learn more about JNDI and related issues. Make sure these values are all correct before you try running the client.</p>
  <p>After you have set up your classpath, to invoke this sample using WSIF's DII, run the <tt>Run</tt> class located in this directory. This is the logic that uses the generated stub interface to run the sample. So you can run this class, specifying on the command line the location of the WSDL file for the sample. For example, <br>
  <tt>java ejb.client.stub.Run samples/ejb/AddressBook.wsdl</tt></p>
  <p>The sample code will use the stub interface to populate an addressbook with two entries and will then query the addressbook for those two addresses using the corresponding names.</p>
  <p>To generate the stub interface, you can use any tool that generates Java interfaces for WSDL services using their port type descriptions, such as WSDL2Java from Axis. WSIF assumes a correspondence between the generated Java interface and the WSDL port type that has its abstract description as specified in the JAX-RPC specification. This particular sample did not use WSDL2Java in a simple way (due to a current bug in WSDL2Java that prevents it from processing WSDLs that do not have a valid SOAP endpoint or binding. We managed to get it to work by commenting out the EJB binding that is currently there, and introducing a binding element that describes a SOAP binding. After doing this, we ran WSDL2Java in the following way:<br>
  <tt>java org.apache.axis.wsdl.WSDL2Java ../../AddressBook.wsdl</tt><br>
  After the tool finished running, we deleted all the generated files except <tt>AddressBook.java</tt> (this is the java interface corresponding to the port type), <tt>Address.java</tt> and <tt>Phone.java</tt> (these two are the java representations of the complex schema types used in the sample).</p>
  <hr width="100%">
  </body></html>
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/client/stub/Run.java
  
  Index: Run.java
  ===================================================================
  package ejb.client.stub;
  
  import java.rmi.RemoteException;
  
  import ejb.service.addressbook.wsifservice.AddressBook;
  import ejb.service.addressbook.wsiftypes.Address;
  import ejb.service.addressbook.wsiftypes.Phone;
  
  import org.apache.wsif.WSIFException;
  import org.apache.wsif.WSIFService;
  import org.apache.wsif.WSIFServiceFactory;
  
  /**
   * Class that runs the ejb sample using a pregenerated stub interface
   * To use this class provide the location of the address book service's WSDL 
   * location on the command line. WSIF 
   * should then invoke the EJB service for populating and then
   * querying an addressbook.
   * @author Nirmal K. Mukhi (nmukhi@us.ibm.com)
   */
  
  public class Run {
      private static void addFirstAddress(AddressBook addressBook) {
          try {
          	
              // create an address object to populate the input
              Address address = new Address();
              address.setStreetNum(25);
              address.setStreetName("Willow Road");
              address.setCity("MyTown");
              address.setState("PA");
              address.setZip(28382);
              Phone phone = new Phone();
              phone.setAreaCode(288);
              phone.setExchange("555");
              phone.setNumber("9891");
              address.setPhoneNumber(phone);
  
              // do the invocation
              System.out.println("Adding address for John Smith...");
              addressBook.addEntry("John Smith", address);
  
          } catch (WSIFException we) {
              System.out.println("Got exception from WSIF, details:");
              we.printStackTrace();
          } catch (RemoteException re) {
              System.out.println("Got exception while invoking stub, details:");
              re.printStackTrace();
          }
      }
  
      private static void addSecondAddress(AddressBook addressBook) {
          try {
          	
              // create an address object to populate the input
              Address address = new Address();
              address.setStreetNum(20);
              address.setStreetName("Peachtree Avenue");
              address.setCity("Atlanta");
              address.setState("GA");
              address.setZip(39892);
              Phone phone = new Phone();
              phone.setAreaCode(701);
              phone.setExchange("555");
              phone.setNumber("8721");
              address.setPhoneNumber(phone);
  
              // do the invocation
              System.out.println("Adding address for Jane White...");
              addressBook.addEntry("Jane", "White", address);
  
          } catch (WSIFException we) {
              System.out.println("Got exception from WSIF, details:");
              we.printStackTrace();
          } catch (RemoteException re) {
              System.out.println("Got exception while invoking stub, details:");
              re.printStackTrace();
          }
      }
  
      private static void queryAddresses(AddressBook addressBook) {
          try {
  
              // do the invocation
              System.out.println("Querying address for John Smith...");
              Address address = addressBook.getAddressFromName("John Smith");
  
              System.out.println("Service returned the following address:");
              System.out.println(
                  address.getStreetNum()
                      + " "
                      + address.getStreetName()
                      + ", "
                      + address.getCity()
                      + " "
                      + address.getState()
                      + " "
                      + address.getZip()
                      + "; Phone: ("
                      + address.getPhoneNumber().getAreaCode()
                      + ") "
                      + address.getPhoneNumber().getExchange()
                      + "-"
                      + address.getPhoneNumber().getNumber());
  
              System.out.println("Querying address for Jane White...");
              address = addressBook.getAddressFromName("Jane White");
  
              System.out.println("Service returned the following address:");
              System.out.println(
                  address.getStreetNum()
                      + " "
                      + address.getStreetName()
                      + ", "
                      + address.getCity()
                      + " "
                      + address.getState()
                      + " "
                      + address.getZip()
                      + "; Phone: ("
                      + address.getPhoneNumber().getAreaCode()
                      + ") "
                      + address.getPhoneNumber().getExchange()
                      + "-"
                      + address.getPhoneNumber().getNumber());
  
          } catch (WSIFException we) {
              System.out.println("Got exception from WSIF, details:");
              we.printStackTrace();
          } catch (RemoteException re) {
              System.out.println("Got exception while invoking stub, details:");
              re.printStackTrace();
          }
      }
  
      public static void main(String[] args) {
          try {
              if (args.length != 1) {
                  System.out.println(
                      "Usage: java samples.ejb.client.stub.Run <wsdl location>");
                  System.exit(1);
              }
  
              // create a service factory
              WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  
              // parse WSDL
              WSIFService service =
                  factory.getService(
                      args[0],
                      null,
                      null,
                      "http://wsifservice.addressbook/",
                      "AddressBook");
  
              // create the stub
              AddressBook stub =
                  (AddressBook) service.getStub(AddressBook.class);
  
              // do the invocations
              addFirstAddress(stub);
              addSecondAddress(stub);
              queryAddresses(stub);
  
          } catch (WSIFException we) {
              System.out.println("Got exception from WSIF, details:");
              we.printStackTrace();
          }
      }
  }
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/AddressBookSession.java
  
  Index: AddressBookSession.java
  ===================================================================
  /*
   * Generated file - Do not edit!
   */
  package ejb.service;
  
  import java.lang.*;
  import java.util.*;
  import org.w3c.dom.*;
  import javax.xml.parsers.*;
  import java.rmi.RemoteException;
  import javax.ejb.CreateException;
  import javax.ejb.EJBException;
  import javax.ejb.FinderException;
  import javax.ejb.RemoveException;
  import javax.ejb.SessionBean;
  import javax.ejb.SessionContext;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.rmi.PortableRemoteObject;
  import ejb.service.addressbook.wsiftypes.Address;
  
  /**
   * Remote interface for service/AddressBookSession.
   * @xdoclet-generated at Dec 13, 2002 1:41:52 PM
   */
  public interface AddressBookSession
     extends javax.ejb.EJBObject
  {
  
     public void addEntry( java.lang.String name,ejb.service.addressbook.wsiftypes.Address address ) throws java.rmi.RemoteException;
  
     public void addEntry( java.lang.String firstName,java.lang.String lastName,ejb.service.addressbook.wsiftypes.Address address ) throws java.rmi.RemoteException;
  
     public ejb.service.addressbook.wsiftypes.Address getAddressFromName( java.lang.String name ) throws java.lang.IllegalArgumentException, java.rmi.RemoteException;
  
  }
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/AddressBookSessionBean.java
  
  Index: AddressBookSessionBean.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package ejb.service;
  
  import java.util.*;
  import org.w3c.dom.*;
  import javax.xml.parsers.*;
  
  import java.rmi.RemoteException;
  import javax.ejb.CreateException;
  import javax.ejb.EJBException;
  import javax.ejb.FinderException;
  import javax.ejb.RemoveException;
  import javax.ejb.SessionBean;
  import javax.ejb.SessionContext;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.rmi.PortableRemoteObject;
  
  import ejb.service.addressbook.wsiftypes.Address;
  
  /**
   * AddressBook Session Bean
   *
   * ATTENTION: Some of the XDoclet tags are hidden from XDoclet by
   *            adding a "--" between @ and the namespace. Please remove
   *            this "--" to make it active or add a space to make an
   *            active tag inactive.
   *
   * @ejb:bean name="service/AddressBookSession"
   *           display-name="AddressBook Bean"
   *           type="Stateful"
   *           transaction-type="Container"
   *           jndi-name="ejb/service/AddressBook"
   *
   * @ejb:ejb-ref ejb-name="service/AddressBookSession"
   *              ref-name="myservice/AddressBook"
   *
   * @ejb:resource-ref res-name="test/Mail"
   *                   res-type="javax.mail.Session"
   *                   res-auth="Container"
   *
   * @jboss:resource-manager res-man-class="javax.mail.Session"
   *                         res-man-name="test/Mail"
   *                         res-man-jndi-name="java:Mail"
   **/
  public class AddressBookSessionBean implements SessionBean {
      private HashMap name2AddressTable = new HashMap();
      private SessionContext mContext;
  
      /**
       * @ejb:interface-method view-type="remote"
       **/
      public void addEntry(String name, Address address)
      {
  	name2AddressTable.put(name, address);
      }
  
      /**
       * @ejb:interface-method view-type="remote"
       **/
      public void addEntry(String firstName, String lastName, Address address)
      {
  	name2AddressTable.put(firstName+" "+lastName, address);
      }
  
      /**
       * @ejb:interface-method view-type="remote"
       **/
      public Address getAddressFromName(String name)
  	throws IllegalArgumentException
      {
  	return (Address)name2AddressTable.get(name);
      }
  
      /**
       * Create the Session Bean
       *
       * @throws CreateException 
       *
       * @ejb:create-method view-type="remote"
       **/
      public void ejbCreate()
  	throws
  	    CreateException
      {
  	System.out.println( "AddressBookSessionBean.ejbCreate()" );
      }
     
      /**
       * Describes the instance and its content for debugging purpose
       *
       * @return Debugging information about the instance and its content
       **/
      public String toString()
      {
  	return "AddressBookSessionBean [ " + " ]";
      }
     
     
      // -------------------------------------------------------------------------
      // Framework Callbacks
      // -------------------------------------------------------------------------  
     
      public void setSessionContext( SessionContext aContext )
  	throws
  	    EJBException
      {
  	mContext = aContext;
      }
     
      public void ejbActivate()
  	throws
  	    EJBException
      {
      }
     
      public void ejbPassivate()
  	throws
  	    EJBException
      {
      }
     
      public void ejbRemove()
  	throws
  	    EJBException
      {
      }
  }
  
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/AddressBookSessionHome.java
  
  Index: AddressBookSessionHome.java
  ===================================================================
  /*
   * Generated file - Do not edit!
   */
  package ejb.service;
  
  import java.lang.*;
  import java.util.*;
  import org.w3c.dom.*;
  import javax.xml.parsers.*;
  import java.rmi.RemoteException;
  import javax.ejb.CreateException;
  import javax.ejb.EJBException;
  import javax.ejb.FinderException;
  import javax.ejb.RemoveException;
  import javax.ejb.SessionBean;
  import javax.ejb.SessionContext;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.rmi.PortableRemoteObject;
  import ejb.service.addressbook.wsiftypes.Address;
  
  /**
   * Home interface for service/AddressBookSession. Lookup using {1}
   * @xdoclet-generated at Dec 13, 2002 1:41:52 PM
   */
  public interface AddressBookSessionHome
     extends javax.ejb.EJBHome
  {
     public static final String COMP_NAME="java:comp/env/ejb/service/AddressBookSession";
     public static final String JNDI_NAME="ejb/service/AddressBook";
  
     /**
      * Create the Session Bean
      * @throws CreateException
      */
     public ejb.service.AddressBookSession create() throws java.rmi.RemoteException,javax.ejb.CreateException;
  
  }
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/README.html
  
  Index: README.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Nirmal Mukhi">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title>Web Services Invocation Framework: Samples</title>
  <link rel="stylesheet" href="wsif.css" type="text/css"></head>
  
  <body alink="#0000ff" bgcolor="#ffffff" leftmargin="2" topmargin="2" marginwidth="2" marginheight="2">
  
  <h2>
  Web Services Invocation Framework:<br>
  An EJB as a WSDL-described service</h2>
  <p>This directory contains an implementation for a session bean that provides the abstract functionality described in our <a href="../AddressBook.wsdl">AddressBook WSDL</a>. The files contained here are:
  <ul>
        <li><tt><a href="AddressBookSession.java">AddressBookSession.java</a></tt>, the EJB interface for our session bean.</li>
        <li><tt><a href="AddressBookSession.java">AddressBookSessionHome.java</a></tt>, the home interface for our session bean.</li>
        <li><tt><a href="AddressBookSessionBean.java">AddressBookSessionBean.java</a></tt>, the EJBimplementation. This is as vanilla as can be, using a hash table to store a map of names to addresses.</li>
        <li><tt><a href="addressbook">addressbook</a></tt> is a subdirectory containing the complex Java types used - these can be generated from the WSDL</li>
        <li><tt><a href="deploy">deploy</a></tt> is a subdirectory containing the things necessary to deploy this EJB to your favorite application server. Generally to deploy your EJB you will need to compile the code for this sample, then package it into a JAR along with an <tt><a href="deploy/jboss/ejb-jar.xml">ejb-jar.xml</a></tt> file. Your application server may need other files. We have included under the <tt>deploy/jboss</tt> directory a pre-packaged jar that contains the compiled beans and the configuration files required by JBoss. All you need to deploy to JBoss is to drop this <a href="deploy/jboss/addressbook.jar">addressbook JAR file for JBoss</a> (assuming you use the default server configuration) into server/default/deploy under your JBoss server installation, and start your server.</li>
  </ul>
  <hr width="100%">
  </body></html>
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/addressbook/wsifservice/AddressBook.java
  
  Index: AddressBook.java
  ===================================================================
  /**
   * AddressBook.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package ejb.service.addressbook.wsifservice;
  
  public interface AddressBook extends java.rmi.Remote {
      public void addEntry(java.lang.String name, ejb.service.addressbook.wsiftypes.Address address) throws java.rmi.RemoteException;
      public void addEntry(java.lang.String firstName, java.lang.String lastName, ejb.service.addressbook.wsiftypes.Address address) throws java.rmi.RemoteException;
      public ejb.service.addressbook.wsiftypes.Address getAddressFromName(java.lang.String name) throws java.rmi.RemoteException;
  }
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/addressbook/wsiftypes/Address.java
  
  Index: Address.java
  ===================================================================
  /**
   * Address.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package ejb.service.addressbook.wsiftypes;
  
  public class Address  implements java.io.Serializable {
      private int streetNum;
      private java.lang.String streetName;
      private java.lang.String city;
      private java.lang.String state;
      private int zip;
      private ejb.service.addressbook.wsiftypes.Phone phoneNumber;
  
      public Address() {
      }
  
      public int getStreetNum() {
          return streetNum;
      }
  
      public void setStreetNum(int streetNum) {
          this.streetNum = streetNum;
      }
  
      public java.lang.String getStreetName() {
          return streetName;
      }
  
      public void setStreetName(java.lang.String streetName) {
          this.streetName = streetName;
      }
  
      public java.lang.String getCity() {
          return city;
      }
  
      public void setCity(java.lang.String city) {
          this.city = city;
      }
  
      public java.lang.String getState() {
          return state;
      }
  
      public void setState(java.lang.String state) {
          this.state = state;
      }
  
      public int getZip() {
          return zip;
      }
  
      public void setZip(int zip) {
          this.zip = zip;
      }
  
      public ejb.service.addressbook.wsiftypes.Phone getPhoneNumber() {
          return phoneNumber;
      }
  
      public void setPhoneNumber(ejb.service.addressbook.wsiftypes.Phone phoneNumber) {
          this.phoneNumber = phoneNumber;
      }
  
      private java.lang.Object __equalsCalc = null;
      public synchronized boolean equals(java.lang.Object obj) {
          if (!(obj instanceof Address)) return false;
          Address other = (Address) obj;
          if (obj == null) return false;
          if (this == obj) return true;
          if (__equalsCalc != null) {
              return (__equalsCalc == obj);
          }
          __equalsCalc = obj;
          boolean _equals;
          _equals = true && 
              streetNum == other.getStreetNum() &&
              ((streetName==null && other.getStreetName()==null) || 
               (streetName!=null &&
                streetName.equals(other.getStreetName()))) &&
              ((city==null && other.getCity()==null) || 
               (city!=null &&
                city.equals(other.getCity()))) &&
              ((state==null && other.getState()==null) || 
               (state!=null &&
                state.equals(other.getState()))) &&
              zip == other.getZip() &&
              ((phoneNumber==null && other.getPhoneNumber()==null) || 
               (phoneNumber!=null &&
                phoneNumber.equals(other.getPhoneNumber())));
          __equalsCalc = null;
          return _equals;
      }
  
      private boolean __hashCodeCalc = false;
      public synchronized int hashCode() {
          if (__hashCodeCalc) {
              return 0;
          }
          __hashCodeCalc = true;
          int _hashCode = 1;
          _hashCode += getStreetNum();
          if (getStreetName() != null) {
              _hashCode += getStreetName().hashCode();
          }
          if (getCity() != null) {
              _hashCode += getCity().hashCode();
          }
          if (getState() != null) {
              _hashCode += getState().hashCode();
          }
          _hashCode += getZip();
          if (getPhoneNumber() != null) {
              _hashCode += getPhoneNumber().hashCode();
          }
          __hashCodeCalc = false;
          return _hashCode;
      }
  }
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/addressbook/wsiftypes/Phone.java
  
  Index: Phone.java
  ===================================================================
  /**
   * Phone.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package ejb.service.addressbook.wsiftypes;
  
  public class Phone  implements java.io.Serializable {
      private int areaCode;
      private java.lang.String exchange;
      private java.lang.String number;
  
      public Phone() {
      }
  
      public int getAreaCode() {
          return areaCode;
      }
  
      public void setAreaCode(int areaCode) {
          this.areaCode = areaCode;
      }
  
      public java.lang.String getExchange() {
          return exchange;
      }
  
      public void setExchange(java.lang.String exchange) {
          this.exchange = exchange;
      }
  
      public java.lang.String getNumber() {
          return number;
      }
  
      public void setNumber(java.lang.String number) {
          this.number = number;
      }
  
      private java.lang.Object __equalsCalc = null;
      public synchronized boolean equals(java.lang.Object obj) {
          if (!(obj instanceof Phone)) return false;
          Phone other = (Phone) obj;
          if (obj == null) return false;
          if (this == obj) return true;
          if (__equalsCalc != null) {
              return (__equalsCalc == obj);
          }
          __equalsCalc = obj;
          boolean _equals;
          _equals = true && 
              areaCode == other.getAreaCode() &&
              ((exchange==null && other.getExchange()==null) || 
               (exchange!=null &&
                exchange.equals(other.getExchange()))) &&
              ((number==null && other.getNumber()==null) || 
               (number!=null &&
                number.equals(other.getNumber())));
          __equalsCalc = null;
          return _equals;
      }
  
      private boolean __hashCodeCalc = false;
      public synchronized int hashCode() {
          if (__hashCodeCalc) {
              return 0;
          }
          __hashCodeCalc = true;
          int _hashCode = 1;
          _hashCode += getAreaCode();
          if (getExchange() != null) {
              _hashCode += getExchange().hashCode();
          }
          if (getNumber() != null) {
              _hashCode += getNumber().hashCode();
          }
          __hashCodeCalc = false;
          return _hashCode;
      }
  }
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/deploy/jboss/addressbook.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/deploy/jboss/ejb-jar.xml
  
  Index: ejb-jar.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
  
  <ejb-jar >
  
     <description>No Description.</description>
     <display-name>Generated by XDoclet</display-name>
  
     <enterprise-beans>
  
        <!-- Session Beans -->
        <session >
           <description><![CDATA[AddressBook Session Bean ATTENTION: Some of the XDoclet tags are hidden from XDoclet by adding a "--" between @ and the namespace.]]></description>
           <display-name>AddressBook Bean</display-name>
  
           <ejb-name>ejb/service/AddressBookSession</ejb-name>
  
           <home>ejb.service.AddressBookSessionHome</home>
           <remote>ejb.service.AddressBookSession</remote>
           <ejb-class>ejb.service.AddressBookSessionBean</ejb-class>
           <session-type>Stateful</session-type>
           <transaction-type>Container</transaction-type>
  
        </session>
  
       <!--
         To add session beans that you have deployment descriptor info for, add
         a file to your merge directory called session-beans.xml that contains
         the <session></session> markup for those beans.
       -->
  
        <!-- Entity Beans -->
  
       <!--
         To add entity beans that you have deployment descriptor info for, add
         a file to your merge directory called entity-beans.xml that contains
         the <entity></entity> markup for those beans.
       -->
  
        <!-- Message Driven Beans -->
       <!--
         To add message driven beans that you have deployment descriptor info for, add
         a file to your merge directory called message-driven-beans.xml that contains
         the <message-driven></message-driven> markup for those beans.
       -->
  
     </enterprise-beans>
  
     <!-- Relationships -->
  
     <!-- Assembly Descriptor -->
     <assembly-descriptor >
  
     <!-- finder permissions -->
  
     <!-- transactions -->
  
     <!-- finder transactions -->
     </assembly-descriptor>
  
  </ejb-jar>
  
  
  
  1.1                  xml-axis-wsif/java/samples/ejb/service/deploy/jboss/jboss.xml
  
  Index: jboss.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
  
  <jboss>
  
     <enterprise-beans>
  
        <session>
           <ejb-name>ejb/service/AddressBookSession</ejb-name>
           <jndi-name>ejb/service/AddressBook</jndi-name>
        </session>
  
     </enterprise-beans>
  
     <resource-managers>
        <resource-manager res-class="javax.mail.Session">
           <res-name>test/Mail</res-name>
           <res-jndi-name>java:Mail</res-jndi-name>
        </resource-manager>
     </resource-managers>
  
  </jboss>