package com.primeton.eos;
import javax.xml.namespace.QName;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public class RPCClient {
public static Object callWS(String wsAddress, String paramer,
String nameSpace, String method) throws Exception {
RPCServiceClient serviceClient;
serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
// 指定调用WebService的URL
EndpointReference targetEPR = new EndpointReference(wsAddress);
options.setTo(targetEPR);
// 指定method方法的参数值
Object[] opAddEntryArgs = new Object[] { paramer };
// 指定method方法返回值的数据类型的Class对象
Class[] classes = new Class[] { Integer.class };
// 指定要调用的WSDL文件的命名空间及method方法
QName opAddEntry = new QName(nameSpace, method);
// 调用getGreeting方法并输出该方法的返回值
return serviceClient
.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0];
}
public static void main(String[] args) throws Exception {
Integer result = (Integer) callWS("http://127.0.0.1:8080/default/ECService",
"6180", "http://www.primeton.com/ECService", "getSnFromECS");
System.out.println(result);
}
}
import javax.xml.namespace.QName;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public class RPCClient {
public static Object callWS(String wsAddress, String paramer,
String nameSpace, String method) throws Exception {
RPCServiceClient serviceClient;
serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
// 指定调用WebService的URL
EndpointReference targetEPR = new EndpointReference(wsAddress);
options.setTo(targetEPR);
// 指定method方法的参数值
Object[] opAddEntryArgs = new Object[] { paramer };
// 指定method方法返回值的数据类型的Class对象
Class[] classes = new Class[] { Integer.class };
// 指定要调用的WSDL文件的命名空间及method方法
QName opAddEntry = new QName(nameSpace, method);
// 调用getGreeting方法并输出该方法的返回值
return serviceClient
.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0];
}
public static void main(String[] args) throws Exception {
Integer result = (Integer) callWS("http://127.0.0.1:8080/default/ECService",
"6180", "http://www.primeton.com/ECService", "getSnFromECS");
System.out.println(result);
}
}