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>

axis2调用WSDL接口的更多相关文章

  1. C# 不添加WEB引用调用WSDL接口

    在项目中添加WEB引用耦合度较高,更新时要更新引用,所以我建议不添加WEB引用调用WSDL接口,废话不多说,直接上代码 例如WSDL地址为:http://XXX.XX.XXX.XXX:9115/WsP ...

  2. php7-soap调用wsdl接口报错:Could not connect to host

    由php5.6升级到php7.1以上版本,在用soap调用wsdl接口是报错:Could not connect to host 后来经过排查是centos服务器上装有2个版本的openssl造成的. ...

  3. java-webService(调用wsdl接口)

    使用Axis或XFire实现WebService: Axis2是Apache下的一个重量级WebService框架,准确说它是一个Web Services / SOAP / WSDL 的引擎,是Web ...

  4. [Java] java调用wsdl接口

    前提: ① 已经提供了一个wsdl接口 ② 该接口能正常调用 步骤1:使用cxf的wsdl2java工具生成本地类 下载CXF:http://cxf.apache.org/download.html ...

  5. CXF动态调用wsdl接口

    1.application.properties文件中配置接口url 2.工具类 package com.vulnverify.core.utils; import java.io.IOExcepti ...

  6. C#/Java 调用WSDL接口及方法

    一.C#利用vs里面自带的“添加web引用”功能: 1.首先需要清楚WSDL的引用地址  如:http://www.webxml.com.cn/Webservices/WeatherWebServic ...

  7. thinkphp 调用wsdl接口实例化SoapClient抛出异常

    异常:Message:SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://*****?wsdl' : failed to load externa ...

  8. PHP调用wsdl接口实例化SoapClient抛出异常

    异常:Message:SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://*****?wsdl' : failed to load externa ...

  9. Java调用WSDL接口

    1.首先准备jar包: 2.代码调用如下: String url="url地址"; QName qName=new QName("命名空间","接口名 ...

随机推荐

  1. WORD与DWORD

    在看C/C++的书或者试题时,有时会见到利用word或dword定义的变量,第一次看到的时候并不知其是什么,更不用说word或dword占几个字节了.幸好在VC安装文件夹下有相关的定义.如C:\Pro ...

  2. 用函数式编程思维解析anagrams函数

    //函数式编程思维分析 这个排列函数 const anagrams = str => { if (str.length <= 2) return str.length === 2 ? [s ...

  3. 响应式web设计视图工具及插件总结----20150113

    响应式web设计可以说火不火是迟早的,下面就对于最开始的视口调试的方法汇总,希望有好的方法大家一起交流. 1.火狐:从Firefox升级到29.0之后就不直接支持Firesizer了. 先安装Add- ...

  4. C++系统学习一:基本数据类型和变量

    程序语言 程序语言最基本的特征 整型.字符型等内置类型 变量,用来为对象命名 表达式和语句,操纵上述数据类型的具体值 if等控制结构 函数,定义可供随时调用的计算单元 程序语言的扩展 自定义数据类型 ...

  5. Linux基础学习-数据备份工具Rsync

    数据备份工具rsync 作为一个系统管理员,数据备份是非常重要的,如果没有做好备份策略,磁盘损坏了,那么你的数据将全部丢失,所以在日常的维护工作中,一定要时刻牢记给数据做备份. rsync不仅可以可以 ...

  6. 分析laravel的核心日志类

    首先是容器 log对应的是application这个容器 首先我们查看如何获取这个日志类,我们来到\storage\app.php中找到application这个容器,点进去, 我们来到了 点击这个跳 ...

  7. 剑指Offer(书):链表中环的入口节点

    题目:给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null. public ListNode EntryNodeOfLoop(ListNode pHead) { //第一步,查找是 ...

  8. 经典DP问题--poj1088滑雪

    Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道 ...

  9. 自学入门 Python 优质中文资源索引

    所有资源基于 Python3 版本,全部中文内容,适用于 爬虫 / Web / 数据 方向,每个单元根据学习习惯从 书籍 / 文档 / 视频 中选择一类即可,建议任选一本书籍,然后配合文档类进行学习. ...

  10. spring-boot-mustach-template

    spring模板引擎mustache https://www.baeldung.com/spring-boot-mustache 这篇文章文件的名字都是.html结尾自己试了下并不行 需要将.html ...