package text.yyu;
public class UrlService {
/*第三方调用webservice执行方法总入口*/
public static String service(String json){
try {
/**
* NxServiceAgent 项目名称
* services web.xml配置的url
* ServiceAgent 暴漏的接口名字
*/
final String endpoint = "接口url地址 // 如-》 http://localhost:8080/NxServiceAgent/services/ServiceAgent";
String opName = "execute";//接口暴漏的方法名
String param=json; //传入的参数
Object[] opArgs = new Object[] { param };
Class<?>[] opReturnType = new Class[] { String[].class };
RPCServiceClient serviceClient = new RPCServiceClient();//此处RPCServiceClient 对象实例建议定义成类中的static变量,否则多次调用会出现连接超时的错误。
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference(endpoint);
options.setTo(targetEPR);
QName opQName = new QName("http://ws.wondersgroup.com",opName);
Object[] ret = serviceClient.invokeBlocking(opQName, opArgs,
opReturnType);
return ((String[]) ret[0])[0];
} catch (AxisFault e) {
e.printStackTrace();
}
return null;
}
}
axis2 webService项目 客户端生成方法
最新推荐文章于 2018-09-17 10:13:21 发布