topical media & game development
professional-xml-19-Listing-19-12.txt / txt
package com.wrox.webservices;
import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.utils.Options;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class ProductClient
{
public static void main(String [] args) throws Exception
{
Options options = new Options(args);
Service service = new Service();
Call call = (Call) service.createCall();
QName qn = new QName( "urn:ProductService", "Product" );
call.registerTypeMapping(Product.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(Product.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(Product.class,
qn));
Product result = null;
try {
call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
call.setOperationName( new QName("ProductProcessor", "getProduct") );
call.addParameter("productID", org.apache.axis.encoding.XMLType.XSD_INT,
ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_ANYTYPE);
result = (Product) call.invoke( new Object[] { 1 } );
}
catch (AxisFault fault) {
System.out.println("Error : " + fault.toString());
}
System.out.println("Name : " + result.getName());
System.out.println("Product ID : " + result.getProductID());
System.out.println("Product Number : " + result.getProductNumber());
System.out.println("Colr : " + result.getColor());
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.