nmukhi 2002/12/11 12:38:40
Added: java/samples/localjava AddressBook.wsdl
java/samples/localjava/client/dynamic README.html Run.java
java/samples/localjava/client/stub README.html Run.java
java/samples/localjava/client/stub/addressbook/wsifservice
AddressBook.java
java/samples/localjava/client/stub/addressbook/wsiftypes
Address.java Phone.java
java/samples/localjava/service AddressBookImpl.java
Log:
Files for local java invocation sample
Revision Changes Path
1.1 xml-axis-wsif/java/samples/localjava/AddressBook.wsdl
Index: AddressBook.wsdl
===================================================================
<?xml version="1.0" ?>
<definitions targetNamespace="http://wsifservice.addressbook/"
xmlns:tns="http://wsifservice.addressbook/"
xmlns:typens="http://wsiftypes.addressbook/"
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:java="http://schemas.xmlsoap.org/wsdl/java/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<!-- type defs -->
<types>
<xsd:schema
targetNamespace="http://wsiftypes.addressbook/"
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="JavaBinding" type="tns:AddressBook">
<java:binding/>
<format:typeMapping encoding="Java" style="Java">
<format:typeMap typeName="typens:address"
formatType="addressbook.wsiftypes.Address" />
<format:typeMap typeName="xsd:string" formatType="java.lang.String" />
</format:typeMapping>
<operation name="addEntry">
<java:operation
methodName="addEntry"
parameterOrder="name address"
methodType="instance" />
<input name="AddEntryWholeNameRequest"/>
</operation>
<operation name="addEntry">
<java:operation
methodName="addEntry"
parameterOrder="firstName lastName address"
methodType="instance" />
<input name="AddEntryFirstAndLastNamesRequest"/>
</operation>
<operation name="getAddressFromName">
<java:operation
methodName="getAddressFromName"
parameterOrder="name"
methodType="instance"
returnPart="address" />
<input name="GetAddressFromNameRequest"/>
<output name="GetAddressFromNameResponse"/>
</operation>
</binding>
<!-- service decln -->
<service name="AddressBookService">
<port name="JavaPort" binding="tns:JavaBinding">
<java:address className="localjava.service.AddressBookImpl"/>
</port>
</service>
</definitions>
1.1 xml-axis-wsif/java/samples/localjava/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 Java Sample using WSIF's dynamic invocation interface</h2>
<p>You must have the following on your classpath:
<ul>
<li>wsif.jar</li>
<li>wsifsamples.jar</li>
<li>A JAXP compliant XML parser, such as Xerces</li>
<li>wsdl4j.jar</li>
<li>qname.jar</li>
</ul>
</p>
<p>After you have set up the CLASSPATH in your environment, 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
samples.java.clients.dynamic.Run samples/java/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/localjava/client/dynamic/Run.java
Index: Run.java
===================================================================
package localjava.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 addressbook.wsiftypes.Address;
import 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("addressbook.wsiftypes.Address"));
service.mapType(new QName("http://wsiftypes.addressbook/","Phone"),
Class.forName("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/localjava/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 SimpleSOAP Sample through a high level stub interface</h2>
<p>You must have the following on your classpath:
<ul>
<li>wsif.jar</li>
<li>wsifsamples.jar</li>
<li>A JAXP compliant XML parser, such as Xerces</li>
<li>wsdl4j.jar</li>
<li>qname.jar</li>
<li>axis.jar (since by default WSIF uses its Axis provider to invoke SOAP
services)</li>
<li>JAR files required by Axis - log4j.jar, commons-logging.jar, jaxrpc.jar,
saaj.jar</li>
</ul>
</p>
<p>This directory contains a file called <tt>Run.java</tt> that contains the
<tt>main</tt> method. 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 and the symbol for the company whose stock quote you are
interested in. For example, <br>
<tt>java samples.SimpleSOAP.client.static.Run
file:/mywsifinstallation/samples/SimpleSOAP/StockquoteSOAP.wsdl IBM</tt></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 used WSDL2Java in the following way:<br>
<tt>java org.apache.axis.wsdl.WSDL2Java ../../StockquoteSOAP.wsdl</tt><br>
After the tool finished running, we deleted all the generated files except
<tt>NetXmethodsServicesStockquoteStockQuotePortType.java</tt> (this is the java
interface corresponding to the port type and is all that is required by WSIF).</p>
<hr width="100%">
</body></html>
1.1 xml-axis-wsif/java/samples/localjava/client/stub/Run.java
Index: Run.java
===================================================================
package localjava.client.stub;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.wsif.WSIFException;
import java.rmi.RemoteException;
import addressbook.wsiftypes.Address;
import addressbook.wsiftypes.Phone;
import addressbook.wsifservice.AddressBook;
/**
* Class that runs the localjava 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 local java service for populating and then
* querying an addressbook.
* @author Nirmal K. Mukhi ([EMAIL PROTECTED])
*/
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.localjava.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");
AddressBook stub = null;
// create the stub
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/localjava/client/stub/addressbook/wsifservice/AddressBook.java
Index: AddressBook.java
===================================================================
/**
* AddressBook.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package addressbook.wsifservice;
public interface AddressBook extends java.rmi.Remote {
public void addEntry(java.lang.String name, addressbook.wsiftypes.Address
address) throws java.rmi.RemoteException;
public void addEntry(java.lang.String firstName, java.lang.String lastName,
addressbook.wsiftypes.Address address) throws java.rmi.RemoteException;
public addressbook.wsiftypes.Address getAddressFromName(java.lang.String name)
throws java.rmi.RemoteException;
}
1.1
xml-axis-wsif/java/samples/localjava/client/stub/addressbook/wsiftypes/Address.java
Index: Address.java
===================================================================
/**
* Address.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package 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 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 addressbook.wsiftypes.Phone getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(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;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(Address.class);
static {
org.apache.axis.description.FieldDesc field = new
org.apache.axis.description.ElementDesc();
field.setFieldName("streetNum");
field.setXmlName(new javax.xml.namespace.QName("", "streetNum"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "int"));
typeDesc.addFieldDesc(field);
field = new org.apache.axis.description.ElementDesc();
field.setFieldName("streetName");
field.setXmlName(new javax.xml.namespace.QName("", "streetName"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "string"));
typeDesc.addFieldDesc(field);
field = new org.apache.axis.description.ElementDesc();
field.setFieldName("city");
field.setXmlName(new javax.xml.namespace.QName("", "city"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "string"));
typeDesc.addFieldDesc(field);
field = new org.apache.axis.description.ElementDesc();
field.setFieldName("state");
field.setXmlName(new javax.xml.namespace.QName("", "state"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "string"));
typeDesc.addFieldDesc(field);
field = new org.apache.axis.description.ElementDesc();
field.setFieldName("zip");
field.setXmlName(new javax.xml.namespace.QName("", "zip"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "int"));
typeDesc.addFieldDesc(field);
field = new org.apache.axis.description.ElementDesc();
field.setFieldName("phoneNumber");
field.setXmlName(new javax.xml.namespace.QName("", "phoneNumber"));
field.setXmlType(new
javax.xml.namespace.QName("http://wsiftypes.addressbook/", "phone"));
typeDesc.addFieldDesc(field);
};
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
1.1
xml-axis-wsif/java/samples/localjava/client/stub/addressbook/wsiftypes/Phone.java
Index: Phone.java
===================================================================
/**
* Phone.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package 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;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(Phone.class);
static {
org.apache.axis.description.FieldDesc field = new
org.apache.axis.description.ElementDesc();
field.setFieldName("areaCode");
field.setXmlName(new javax.xml.namespace.QName("", "areaCode"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "int"));
typeDesc.addFieldDesc(field);
field = new org.apache.axis.description.ElementDesc();
field.setFieldName("exchange");
field.setXmlName(new javax.xml.namespace.QName("", "exchange"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "string"));
typeDesc.addFieldDesc(field);
field = new org.apache.axis.description.ElementDesc();
field.setFieldName("number");
field.setXmlName(new javax.xml.namespace.QName("", "number"));
field.setXmlType(new
javax.xml.namespace.QName("http://www.w3.org/1999/XMLSchema", "string"));
typeDesc.addFieldDesc(field);
};
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
1.1
xml-axis-wsif/java/samples/localjava/service/AddressBookImpl.java
Index: AddressBookImpl.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 [EMAIL PROTECTED]
*
* 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 localjava.service;
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import addressbook.wsiftypes.Address;
import addressbook.wsiftypes.Phone;
import addressbook.wsifservice.AddressBook;
/**
* Sample service that provides add/get functionality.
*
* @author Matthew J. Duftler ([EMAIL PROTECTED])
* @author Aleksander Slominski
* @author Nirmal Mukhi
*/
public class AddressBookImpl implements AddressBook {
private HashMap name2AddressTable = new HashMap();
public AddressBookImpl() { }
public void addEntry(String name, Address address)
{
name2AddressTable.put(name, address);
}
public void addEntry(String firstName, String lastName, Address address)
{
name2AddressTable.put(firstName+" "+lastName, address);
}
public Address getAddressFromName(String name)
throws IllegalArgumentException
{
return (Address)name2AddressTable.get(name);
}
}