MyEclipse8.6整合Axis2插件

1.下载axis2的eclipse插件.
点击附件即可,不要到其他地方下载。
[img]http://dl.iteye.com/upload/picture/pic/95532/1c1ca293-7320-3d6b-8fbe-5215285da64f.jpg[/img]
2.把下好的两个插件包解压后放置myeclipse8.6安装目录下的dropins文件夹中。
笔者本机的实例目录: [color=orange]D:\Genuitec\MyEclipse-8.6\dropins[/color]
[color=red]Axis2_Service_Archiver_1.3.0[/color]和[color=red]Axis2_Codegen_Wizard_1.3.0[/color]要直接放在
[color=orange]D:\Genuitec\MyEclipse-8.6\dropins[/color]目录下,不要把[color=blue]axis2-eclipse-codegen-wizard[/color]和[color=blue]axis2-eclipse-service-archiver-wizard[/color]目录放在[color=orange]D:\Genuitec\MyEclipse-8.6\dropins[/color]下面。
[img]http://dl.iteye.com/upload/picture/pic/95530/4507cfd5-09ff-3b96-8663-7db6bbe44ae9.jpg[/img]
[img][/img]

3.重启MyEclipse8.6后 File->New->Other
[img]http://dl.iteye.com/upload/picture/pic/95534/411bff86-9d9c-30a6-b81a-0ffc0e91ac3d.jpg[/img]


到此Axis2插件安装完毕。 :D

用MyEclipse8.6建立Web Project工程,建完工程后要把axis2-1.5.4-bin.zip目录的lib目录下的所有jar文件加载到工程里。
并创建HelloServer.java文件:
package axis2.service.server;

public class HelloServer {

public String sayHello(String name){
return "Hello, " + name + "!";
}
}

[img]http://dl.iteye.com/upload/picture/pic/95556/14bcc2a7-431c-31ed-ab6a-583893acc224.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/95558/ff5c2bf6-4eb6-36a0-ac7a-a3f3db150722.jpg[/img]
File->New->Other->Axis2 Wizards
[img]http://dl.iteye.com/upload/picture/pic/95560/82c96f23-3304-3d4e-b598-cc76f0764551.jpg[/img]
选中Axis2 Code Generator
[img]http://dl.iteye.com/upload/picture/pic/95562/b824842d-760e-3d0e-9c37-4a55a6e81764.jpg[/img]
在Fully Qualified Class Name处填写服务端的Java类全路径。
单击Add Folder按钮,选择到工程的classes目录,然后单击Test Class Loading按钮,如果显示为Class file loaded successfully则成功了。
[img]http://dl.iteye.com/upload/picture/pic/95564/94f9d038-3c59-35c7-af6d-5a5dd9a38757.jpg[/img]
选择在工程里添加WSDL文件并在Output location处填写生成wsdl文件的路径,Output file name为wsdl文件的名字。
[img]http://dl.iteye.com/upload/picture/pic/95566/57373378-ce30-3c59-9094-a7c52bd44de9.jpg[/img]
然后刷新工程的src目录,这时会看见在Output location目录下会出现wsdl文件。
右键单击工程名字 New-Other
[img]http://dl.iteye.com/upload/picture/pic/95584/99f7a547-d033-36ad-a2cb-1c9cc0d8cae4.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/95588/bc64cf37-8490-398f-b412-4dba930c7222.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/95590/681ba982-50d4-3926-89da-66e07589d902.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/95592/5d255260-a4bd-3904-b645-68eb7cb2190b.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/95594/b8c45e30-c913-3482-b2b0-5b9bc5294fe0.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/95596/a8e14907-5025-3308-adf7-e3be18d12d81.jpg[/img]这个地方填写完Class name后面的[color=red]axis2.service.server.HelloServer[/color]后单击Load按钮可能会报找不到[color=red]axis2.service.server.HelloServer[/color], 这个地方要等一下下, 等长一点儿时间再重新单击一次Load按钮就会好的。
[img]http://dl.iteye.com/upload/picture/pic/95598/e4659898-9424-3f09-9e2b-0940f411fc34.jpg[/img]
单击Finish完成,好了,刷新一下项目,可以看到结构图如下:
[img]http://dl.iteye.com/upload/picture/pic/95600/a8a7ef17-3abe-3788-9272-ffeaa6c6bbcf.jpg[/img]
可以看到在services目录下多了个sayhello_service.aar包。
编辑web.xml加入如下代码:
<servlet> 
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

用MyEclipse8.6把工程发布到Tomcat下面, 这里笔者用的是Tomcat7.0。
启动Tomcat7.0后访问工程:
http://localhost:8081/TestAxis2Ws/services/HelloService?wsdl
<?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://server.service.axis2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://server.service.axis2">
<wsdl:documentation>HelloService</wsdl:documentation>
- <wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://server.service.axis2">
- <xs:element name="sayHello">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="sayHelloResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
- <wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="ns:sayHello" />
</wsdl:message>
- <wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="ns:sayHelloResponse" />
</wsdl:message>
- <wsdl:portType name="HelloServicePortType">
- <wsdl:operation name="sayHello">
<wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello" />
<wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="HelloServiceSoap11Binding" type="ns:HelloServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="sayHello">
<soap:operation soapAction="urn:sayHello" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="HelloServiceSoap12Binding" type="ns:HelloServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="sayHello">
<soap12:operation soapAction="urn:sayHello" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="HelloServiceHttpBinding" type="ns:HelloServicePortType">
<http:binding verb="POST" />
- <wsdl:operation name="sayHello">
<http:operation location="HelloService/sayHello" />
- <wsdl:input>
<mime:content type="text/xml" part="sayHello" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" part="sayHello" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="HelloService">
- <wsdl:port name="HelloServiceHttpSoap11Endpoint" binding="ns:HelloServiceSoap11Binding">
<soap:address location="http://localhost:8081/TestAxis2Ws/services/HelloService.HelloServiceHttpSoap11Endpoint/" />
</wsdl:port>
- <wsdl:port name="HelloServiceHttpSoap12Endpoint" binding="ns:HelloServiceSoap12Binding">
<soap12:address location="http://localhost:8081/TestAxis2Ws/services/HelloService.HelloServiceHttpSoap12Endpoint/" />
</wsdl:port>
- <wsdl:port name="HelloServiceHttpEndpoint" binding="ns:HelloServiceHttpBinding">
<http:address location="http://localhost:8081/TestAxis2Ws/services/HelloService.HelloServiceHttpEndpoint/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值