先说一下基本的知识点。

  SOAP: Simple Object AccessProtocol。它是一种用于访问 Web 服务的协议。因为 SOAP 基于XML 和 HTTP ,其通过XML 来实现消息描述,然后再通过 HTTP 实现消息传输。SOAP 是用于在应用程序之间进行通信的一种通信协议。它包括四个部分:SOAP封装(envelop),封装定义了一个描述消息中的内容是什么,是谁发送的,谁应当接受并处理它以及如何处理它们的框架;SOAP编码规则(encoding rules),用于表示应用程序需要使用的数据类型的实例; SOAP RPC表示(RPC representation),表示远程过程调用和应答的协定;SOAP绑定(binding),使用底层协议交换信息。

  axis:Axis本质上就是一个SOAP引擎,提供创建服务器端、客户端和网关SOAP操作的基本框架。能够处理SOAP和来自W3C的各种XML标准。

  在axis2调用webservice服务之前,需要做几项准备工作:

  1、 导入axis2的包。pom.xml文件如下:

  

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4 
 5     <groupId>com.bigbang.cxf</groupId>
 6     <artifactId>cxfclient</artifactId>
 7     <version>0.0.1-SNAPSHOT</version>
 8     <packaging>jar</packaging>
 9 
10     <name>cxfclient</name>
11     <url>http://maven.apache.org</url>
12 
13     <properties>
14         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15         <axis.version>1.7.5</axis.version>
16     </properties>
17 
18     <dependencies>
19         <dependency>
20             <groupId>junit</groupId>
21             <artifactId>junit</artifactId>
22             <version>3.8.1</version>
23             <scope>test</scope>
24         </dependency>
25 
26         <!-- axis2 -->
27         <dependency>
28             <groupId>org.apache.axis2</groupId>
29             <artifactId>axis2-kernel</artifactId>
30             <version>${axis.version}</version>
31         </dependency>
32         <dependency>
33             <groupId>org.apache.axis2</groupId>
34             <artifactId>axis2-adb</artifactId>
35             <version>${axis.version}</version>
36         </dependency>
37         <dependency>
38             <groupId>org.apache.axis2</groupId>
39             <artifactId>axis2-transport-http</artifactId>
40             <version>${axis.version}</version>
41         </dependency>
42         <dependency>
43             <groupId>org.apache.axis2</groupId>
44             <artifactId>axis2-transport-local</artifactId>
45             <version>${axis.version}</version>
46         </dependency>
47 
48     </dependencies>
49     <build>
50         <plugins>
51             <plugin>
52                 <groupId>org.mortbay.jetty</groupId>
53                 <artifactId>maven-jetty-plugin</artifactId>
54                 <version>6.1.26</version>
55                 <configuration>
56                     <webAppConfig>
57                         <contextPath>/</contextPath>
58                     </webAppConfig>
59                 </configuration>
60             </plugin>
61 
62             <plugin>
63                 <groupId>org.apache.maven.plugins</groupId>
64                 <artifactId>maven-compiler-plugin</artifactId>
65                 <configuration>
66                     <source>1.8</source>
67                     <target>1.8</target>
68                 </configuration>
69             </plugin>
70         </plugins>
71     </build>
72 </project>
View Code

相关文章: