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";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Java调用ASP.NET的WebService接口实例
共19个文件
png:4个
jar:3个
xml:1个
5星 · 超过95%的资源 需积分: 50 88 下载量 22 浏览量
2018-03-08
17:10:40
上传
评论 4
收藏 1.64MB ZIP 举报
温馨提示
Java调用.NET的WebService接口实例,jar包删减到三个,干净清爽,里面包含注多注释和图解,搞了半天的家伙拿出来与大家分享,无任何BUG,修改里面的参数即可直接运行,对于这种好东西,花了半天时间10分不算高,重在这种分享精神
资源推荐
资源详情
资源评论
收起资源包目录
web.zip (19个子文件)
web
命名空间获取方法
结果.png 9KB
程序开发查看命名空间.png 17KB
已发布网站查看命名空间方法2.png 16KB
已发布网站查看命名空间方法1.png 13KB
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 334B
src
util
webServiceTest.java 2KB
.project 1KB
WebRoot
META-INF
MANIFEST.MF 36B
WEB-INF
web.xml 365B
classes
util
webServiceTest.class 2KB
lib
axiom-api-1.2.20.jar 414KB
axis2-kernel-1.7.4.jar 1001KB
woden-core-1.0M10.jar 365KB
index.jsp 876B
.mymetadata 282B
.classpath 580B
.myeclipse
共 19 条
- 1
资源评论
- s1925252020-02-05感谢您的分享
hu0336
- 粉丝: 6
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功