wsdl接口调用测试

package com.hw.utils;


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 void main(String[] args) throws Exception {
// 使用RPC方式调用WebService
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
// 指定调用WebService的URL
EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8088/axis2/services/TrafficPassService");
options.setTo(targetEPR);
// 指定getGreeting方法的参数值
Object[] opAddEntryArgs = new Object[] { "10000000070417" ,"122"};
// 指定getGreeting方法返回值的数据类型的Class对象
Class[] classes = new Class[] { String.class };
// 指定要调用的getGreeting方法及WSDL文件的命名空间
QName opAddEntry = new QName("http://ws.apache.org/axis2", "upload");
// 调用getGreeting方法并输出该方法的返回值
System.out.println(serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0]);


}
}

猜你喜欢

转载自blog.csdn.net/qq_18972767/article/details/79714049