多平台统一管理软件接口,如何实现多平台统一管理软件接口
578
2022-09-28
java调用webservice的.asmx接口的使用步骤
目录前言一、接口类型二、使用步骤1.访问方式2.导入的maven
前言
接触到一个.asmx结尾的webservice接口,为了增加记忆决定记录下来。
一、接口类型
已.asmx结尾的接口
例:接口地址:http://IP地址/xxx/service/xxx/xxxx.asmx
方法名:test
参数类型:string
二、使用步骤
1.访问方式
代码如下(示例):
controllhttp://er类:
String s = clientUtil.test("http://IP地址/xxx/service/xxx/xxxx.asmx", "test","test");
调用类:
public static String test(String Url, String methodName, String str) throws Exception {
String ref = null;
// webService链接地址
String url = Url;
//获取域名地址,server定义的
String soapaction = "http://tempuri.org/";
Service service = new Service();
try {
Call call OAunZRN= (Call) service.createCall();
call.setTargetEndpointAddress(url);
// 设置要调用哪个方法
call.setOperationName(new QName(soapaction, methodName));
// 设置要传递的参数名
call.addParameter(new QName(soapaction,"str"),org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
// 提供标准类型 有addParameter就必须有setReturnType
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapaction + methodName);
// 调用方法并传递参数
ref = (String) call.invoke(new Object[]{str});
return ref;
} catch (Exception e) {
e.printStackTrace();
}
return ref;
}
2.导入的maven
如下:
参考:
[1]https://blog.csdn.net/qq_34302802/article/details/101197464
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~