1. source file structure :
ProductClient will require services from ProductManger.
so every file contents :
// Product.java
package gmit;
public class Product
{
private String partNumber ;
private String partName ;
private double price ;
public Product(String partNumber, String partName, double price) {
super();
this.partNumber = partNumber;
this.partName = partName;
this.price = price;
}
public String getPartNumber() {
return partNumber;
}
public void setPartNumber(String partNumber) {
this.partNumber = partNumber;
}
public String getPartName() {
return partName;
}
public void setPartName(String partName) {
this.partName = partName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
}
//ProductManger.java
package gmit;
import java.util.*;
public class ProductManager
{
private Map products = new HashMap() ;
public double getPrice(String number) throws Exception
{
if(products.containsKey(number))
{
return products.get(number).getPrice();
}
else
{
throw new Exception("no match number!") ;
}
}
public void addPart(String number, String name , double price )
{
products.put(number, new Product(number,name ,price)) ;
}
public ProductManager()
{
Product p1 = new Product("AB-101", "T-shirt", 10.99) ;
Product p2 = new Product("AB-102", "Jumper", 10.99) ;
products.put(p1.getPartNumber(), p1);
products.put(p2.getPartNumber(), p2);
}
}
// ProductClient.java
package client;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
public class ProductClient
{
public static void main(String[] args)
{
try {
String endpoint = "";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName(""));
call.addParameter("partNumber", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_DOUBLE);
Double ret = (Double) call.invoke( new Object [] {new String("AB-101")});
System.out.println("Got result : " + ret.doubleValue());
} catch (Exception e)
{
e.printStackTrace();
}
}
}
//services.xml
Product Manager
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
gmit.ProductManager
//build.xml
--------> my axis-1_4 home
fork="true"
destdir="${build.dir}/classes"
srcdir="${basedir}/src"
classpathref="axis2.classpath">
outputLocation="${build.dir}"
targetNamespace=""
schemaTargetNamespace="">
---> i copy the aar file to my axis2 serivce fold
;----------------------------------------------------------
2. compile it
3. run the client you will see the results.
use the tcpmoniter:
enter axis1.4 lib directory and
use the command : jar
java -classpath axis.jar org.apache.axis.utils.tcpmon
and then you can see the tcp monitor
4. change the ProductClient.java file, using the port 9999
and configure TCP Moniter listen port at 9999
then add.
when you run the client you will see the following infomation in TCP Moniter:
阅读(628) | 评论(0) | 转发(0) |