axis2调用WSDL接口
2024-08-29 20:30:24
public static JSONObject sendWsdl(String url,String xmlStr){
JSONObject res=new JSONObject();
try {
String endpoint = url.replace("?wsdl","");//不需要传?wsdl
//直接引用远程的wsdl文件
Options options = new Options();
options.setTo(new EndpointReference(endpoint));
ServiceClient sender = new ServiceClient();
sender.setOptions(options); OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/services/IRService","");//参数1(uri)=即为wsdl文档的targetNamespace;参数2(prefix)=可不填
OMElement method = fac.createOMElement("createAuto",omNs);//方法名
OMElement in0 = fac.createOMElement("in0", omNs);//方法参数
in0.setText(xmlStr);//参数值
method.addChild(in0);//添加参数 OMElement resultEle = sender.sendReceive(method);//调用wsdl
System.out.println("调用接口结果:"+resultEle.toString());
}
加入maven依赖:
<!--axis2 begin -->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-spring</artifactId>
<version>1.7.8</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.7.8</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.7.8</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.7.8</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
最新文章
- HTML的基本骨架
- linux 关机要点
- Ubuntu上部署一个简单的Java项目
- 单源最短路径-Dijkstra算法
- 《Python基础教程(第二版)》学习笔记 ->; 第十一章 文件和素材
- bzoj 1064【noi2008】假面舞会
- mac pro 设置wifi热点
- 广告基本知识-ROI分解
- LVS集群之NAT模式实例(3)
- equals()与hashCode()方法协作约定
- docker环境下solr6.0配置(中文分词+拼音)
- angular ng-click防止重复提交
- macOS下MySQL 8.0 安装与配置教程
- SQL Server中如何定位Row Lock锁定哪一行数据
- PTA——完全数
- 前端框架VUE----箭头函数
- Python3 tkinter基础 Frame event.x 输出鼠标左右键点击的位置
- 全网最详细的Oracle10g/11g的官方下载地址集合【可直接迅雷下载安装】(图文详解)
- 阿里云centos系统中配置mysql,并远程连接到本地的navicat
- Dog test1 = new Dog()的解释