例子:
/**
* 返回一个call
* @return
*/
public Call getCall(String methodName){
String endpoint ="http://localhost:8080/test/service/TestService";
Service service = new Service();
Call call = null;
try {
call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName(methodName);
//设置encodingStyle传Integer的时候一定要设置,否则可能会报错,具体原因不明
call.setEncodingStyle("http://localhost:8080/test/service/TestService?wsdl");
} catch (ServiceException e) {
e.printStackTrace();
}
return call;
}
/**
* test
* @param map
* @return
*/
public String handleOP(){
String result = null;
Call call = getCall("beforeReceive");
//设置接口方法的参数
call.addParameter("userNum",XMLType.XSD_INTEGER,ParameterMode.IN);
//设置返回类型,如果要返回一个map类型的就不知道了,反正我没成功过
call.setReturnType(XMLType.XSD_STRING);
try {
Integer param= new Integer(307);
result = (String) call.invoke(new Object[]{param});
} catch (Exception e) {
e.printStackTrace();
}
return result;
}