package util;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import java.rmi.RemoteException;
import java.util.Iterator;
public class webServiceTest
{
public static String test() throws AxisFault {
//在.NET接口中打开asmx相关的cs文件,代码最上边会有[WebService(Namespace = "http://tempuri.org/")]字样
//不知道命名空间的的,在此资料中有个“命名空间.png”图片,可以看下
try {
String url = "http://xxxx.com/xxx.asmx?WSDL";//接口地址
Options options = new Options();
EndpointReference targetEPR = new EndpointReference(url);
options.setTo(targetEPR);
options.setAction("http://tempuri.org/Add");//命名空间+方法名
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMFactory fac = OMAbstractFactory.getOMFactory();
String tns = "http://tempuri.org/";//命名空间
OMNamespace omNs = fac.createOMNamespace(tns, "");
OMElement method = fac.createOMElement("Add", omNs);//Add为方法名
OMElement symbol = fac.createOMElement("qqortel", omNs);//参数名称,如接口上面方法Add(String qqortel),我这里写的和上面一至,没测试不一样是什么结果
symbol.addChild(fac.createOMText(symbol, "13081545944"));//参数值
method.addChild(symbol);
method.build();
OMElement result = sender.sendReceive(method);
return result.toString();
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
return "ERROR";
}
}
![avatar](https://profile-avatar.csdnimg.cn/19de1d973f304284adaa0032fe93322f_hu0336.jpg!1)
hu0336
- 粉丝: 6
- 资源: 17
最新资源
- 打包和分发Rust工具.pdf
- SQL中的CREATE LOGFILE GROUP 语句.pdf
- C语言-leetcode题解之第172题阶乘后的零.zip
- C语言-leetcode题解之第171题Excel列表序号.zip
- C语言-leetcode题解之第169题多数元素.zip
- ocr-图像识别资源ocr-图像识别资源
- 图像识别:基于Resnet50 + VGG16模型融合的人体细胞癌症分类模型实现-图像识别资源
- C语言-leetcode题解之第168题Excel列表名称.zip
- C语言-leetcode题解之第167题两数之和II-输入有序数组.zip
- C语言-leetcode题解之第166题分数到小数.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)