maven配置:主要引用包及plugins

 <properties>
<axis2.version>1.6.1</axis2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>${axis2.version}</version>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.6.1</version>
<executions>
<execution>
<id>wsdl2code-client</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlFile>src/main/resources/wsdl/IXman.wsdl</wsdlFile>
<packageName>com.stub.generated</packageName>
<generateServicesXml>false</generateServicesXml>
<unpackClasses>true</unpackClasses>
</configuration>
</plugin>
</plugins>
</build>

通过wsdlFile属性指定wsdl所在文件。

如果是有多个wsdl需要生成java代码,则可以用下面的配置:

<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>ws1</id>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<unpackClasses>true</unpackClasses>
<databindingName>adb</databindingName>
<packageName>org.example.stackoverflow.axis2-maven</packageName>
<wsdlFile>src/main/resources/service1.wsdl</wsdlFile>
<outputDirectory>target/generated-sources</outputDirectory>
<syncMode>sync</syncMode>
</configuration>
</execution>
<execution>
<id>ws2</id>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<unpackClasses>true</unpackClasses>
<databindingName>adb</databindingName>
<packageName>org.example.stackoverflow.axis2-maven</packageName>
<wsdlFile>src/main/resources/service2.wsdl</wsdlFile>
<outputDirectory>target/generated-sources</outputDirectory>
<syncMode>sync</syncMode>
</configuration>
</execution>
</executions>
</plugin>

注意,这段xml配置,如果使用axis2-wsdl2code:wsdl2code命令去生成会报错,但使用install者可以生成成功。

之后通过中间代码调用即可。

@Test
public void testWs() throws Exception{
AIServiceStub aiServiceStub=new AIServiceStub();
AIRequest aiRequest=new AIRequest();
aiRequest.setMsgHeader("test");
aiRequest.setMsgBody("test");
AIResponse response= aiServiceStub.aIService_visit(aiRequest);
System.out.println(response.getRes());
}

axis2 调用webservice的更多相关文章

  1. Java调用WebService方法总结(5)--Axis2调用WebService

    Axis2是新一点Axis,基于新的体系结构进行了全新编写,有更强的灵活性并可扩展到新的体系结构.文中demo所使用到的软件版本:Java 1.8.0_191.Axis2 1.7.9. 1.准备 参考 ...

  2. axis2调用webservice

    public static long TIMEOUTINMILLISECONDS=100000; /** * 调用webservice * @param url webserviceURL * @pa ...

  3. axis2调用webService几种方式

    主要有三种方式: 第一RPC方式,不生成客户端代码 第二,document方式,不生成客户端代码 第三,用wsdl2java工具,生成客户端方式调用 java代码: package samples.q ...

  4. axis2调用webservice教训

    总结教训,axis2client调用WS接口时url不能加?wsdl,而用cxf调用时则要加上. 今天用axis2的RpcServerClient调用https的webservice接口,在设置完op ...

  5. 使用axis2调用webservice需要导入的依赖

    <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> &l ...

  6. Java调用WebService方法总结(1)--准备工作

    WebService是一种跨编程语言.跨操作系统平台的远程调用技术,已存在很多年了,很多接口也都是通过WebService方式来发布的:本系列文章主要介绍Java调用WebService的各种方法,使 ...

  7. 使用AXIS2客户端调用 WEBSERVICE

    问题 在调用WEBSERVICE时,可以使用wsdl2java生成java代码,调用接口,这种方法在接口固定的情况下是一种不错的选择,如果需要动态调用接口,那么这样就行不通了. 解决办法 1.直接构建 ...

  8. 使用Axis2实现WebService的发布和调用

    一.Axis2的下载和安装 1.可从http://ws.apache.org/axis2/ 下载Axis2的最新版本:      可以下载如下三个zip包: axis2-1.7.3-bin.zip(用 ...

  9. Axis2 webservice 之使用java调用webservice

    在上一篇中写了一个简单了webservice,实现了一个sayHello功能.那么webservice写好之后我们如何使用Java程序来调用webservice呢? 一.java调用的webservi ...

随机推荐

  1. 我用ANDROID STUDIO开发,页面上总包这个警告,很烦!网上说是sdk版本问题,但是我是基于25开发的,最小版本也是19,有没有老司机啊?3克油

  2. 【Codeforces235C】Cyclical Quest 后缀自动机

    C. Cyclical Quest time limit per test:3 seconds memory limit per test:512 megabytes input:standard i ...

  3. JS for循环

    正常的for循环代码: var arr = ['Apple', 'Google', 'Microsoft']; var i, x; for (i=0; i<arr.length; i++) { ...

  4. Data Binding使用技巧

    Data Binding 根据变量,自动赋值到各widget. How 1.编写layout文件,这里的layout为: act_data_bind_demo.xml 这里需要先准备变量 在具体的wi ...

  5. SHELL编写NGINX服务控制脚本

    使用源码包安装的Nginx没办法使用"service nginx start"或"/etc/init.d/nginx start"进行操作和控制,所以写了以下的 ...

  6. HTML5学习总结-番外03 Angular Ionic

    一 Angular Angular使用了MVVC设计模式,MVVC在概念上是真正将页面与数据逻辑分离的模式,它把数据绑定工作放到一个JS里去实现,而这个JS文件的主要功能是完成数据的绑定,即把mode ...

  7. Android SDK NDK开发总结

    描述:http://talent.baidu.com/external/baidu/index.html#/jobDetail/2/1237247043 android studio实现Jni(C/C ...

  8. Nginx是一款面向性能设计的HTTP服务器,相较于Apache、lighttpd具有占有内存少,稳定性高等优势。

    ######Nginx配置文件nginx.conf中文详解######定义Nginx运行的用户和用户组user www www;#nginx进程数,建议设置为等于CPU总核心数.worker_proc ...

  9. UP board 漫谈(1)——从Atom到UP Board

    title: UP board 漫谈(1)--从Atom到UP Board date: 2016-12-26 12:33:03 tags: UP board categories: 开发板 perma ...

  10. linux 卸载编译安装的软件

    有些软件会有 make uninstall 之类的功能,但大多都没有,所以只有手动删除,或者在configure的时候加个preifx参数,比如 --preifx=/opt/squid,这样当你不用的 ...