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>

最新文章

  1. HTML的基本骨架
  2. linux 关机要点
  3. Ubuntu上部署一个简单的Java项目
  4. 单源最短路径-Dijkstra算法
  5. 《Python基础教程(第二版)》学习笔记 -&gt; 第十一章 文件和素材
  6. bzoj 1064【noi2008】假面舞会
  7. mac pro 设置wifi热点
  8. 广告基本知识-ROI分解
  9. LVS集群之NAT模式实例(3)
  10. equals()与hashCode()方法协作约定
  11. docker环境下solr6.0配置(中文分词+拼音)
  12. angular ng-click防止重复提交
  13. macOS下MySQL 8.0 安装与配置教程
  14. SQL Server中如何定位Row Lock锁定哪一行数据
  15. PTA——完全数
  16. 前端框架VUE----箭头函数
  17. Python3 tkinter基础 Frame event.x 输出鼠标左右键点击的位置
  18. 全网最详细的Oracle10g/11g的官方下载地址集合【可直接迅雷下载安装】(图文详解)
  19. 阿里云centos系统中配置mysql,并远程连接到本地的navicat
  20. Dog test1 = new Dog()的解释

热门文章

  1. 新浪oAuth授权
  2. Vue构建项目
  3. ThreadLocal类使用说明
  4. (39)zabbix snmp自定义OID nginx监控实例
  5. perl学习二:简单变量
  6. linux下mysql常用的基本命令
  7. Python中threading的join和setDaemon的区别[带例子]
  8. windows下升级pip失败,重新安装pip最新版本
  9. PAT Basic 1068
  10. MySql update inner join!MySql跨表更新 多表update sql语句?如何将select出来的部分数据update到另一个表里面?