MyEclipse整合axis2

1.下载axis2的eclipse插件.
  点击附件即可,不要到其他地方下载。
 
2.把下好的两个插件包解压后放置myeclipse8.6安装目录下的dropins文件夹中。
  笔者本机的实例目录: D:\Genuitec\MyEclipse-8.6\dropins
  Axis2_Service_Archiver_1.3.0Axis2_Codegen_Wizard_1.3.0要直接放在
  D:\Genuitec\MyEclipse-8.6\dropins目录下,不要把 axis2-eclipse-codegen-wizardaxis2-eclipse-service-archiver-wizard目录放在 D:\Genuitec\MyEclipse-8.6\dropins下面。
 
[img][/img]

3.重启MyEclipse8.6后 File->New->Other
 


到此Axis2插件安装完毕。

用MyEclipse8.6建立Web Project工程,建完工程后要把axis2-1.5.4-bin.zip目录的lib目录下的所有jar文件加载到工程里。
并创建HelloServer.java文件:
Java代码 复制代码  收藏代码
  1. package axis2.service.server;   
  2.   
  3. public class HelloServer {   
  4.        
  5.     public String sayHello(String name){   
  6.         return "Hello, " + name + "!";   
  7.     }   
  8. }  
package axis2.service.server;

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



File->New->Other->Axis2 Wizards

选中Axis2 Code Generator

在Fully Qualified Class Name处填写服务端的Java类全路径。
单击Add Folder按钮,选择到工程的classes目录,然后单击Test Class Loading按钮,如果显示为Class file loaded successfully则成功了。

选择在工程里添加WSDL文件并在Output location处填写生成wsdl文件的路径,Output file name为wsdl文件的名字。

然后刷新工程的src目录,这时会看见在Output location目录下会出现wsdl文件。
右键单击工程名字 New-Other





这个地方填写完Class name后面的 axis2.service.server.HelloServer后单击Load按钮可能会报找不到 axis2.service.server.HelloServer, 这个地方要等一下下, 等长一点儿时间再重新单击一次Load按钮就会好的。

单击Finish完成,好了,刷新一下项目,可以看到结构图如下:

可以看到在services目录下多了个sayhello_service.aar包。
编辑web.xml加入如下代码:
Java代码 复制代码  收藏代码
  1. <servlet>    
  2.         <servlet-name>AxisServlet</servlet-name>    
  3.         <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>    
  4.         <load-on-startup>1</load-on-startup>    
  5. </servlet>    
  6. <servlet-mapping>    
  7.         <servlet-name>AxisServlet</servlet-name>    
  8.         <url-pattern>/services/*</url-pattern>    
  9. </servlet-mapping>  
<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
Java代码 复制代码  收藏代码
  1. <?xml version="1.0" encoding="UTF-8" ?>    
  2. - <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">   
  3.   <wsdl:documentation>HelloService</wsdl:documentation>    
  4. - <wsdl:types>   
  5. - <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://server.service.axis2">   
  6. - <xs:element name="sayHello">   
  7. - <xs:complexType>   
  8. - <xs:sequence>   
  9.   <xs:element minOccurs="0" name="name" nillable="true" type="xs:string" />    
  10.   </xs:sequence>   
  11.   </xs:complexType>   
  12.   </xs:element>   
  13. - <xs:element name="sayHelloResponse">   
  14. - <xs:complexType>   
  15. - <xs:sequence>   
  16.   <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" />    
  17.   </xs:sequence>   
  18.   </xs:complexType>   
  19.   </xs:element>   
  20.   </xs:schema>   
  21.   </wsdl:types>   
  22. - <wsdl:message name="sayHelloRequest">   
  23.   <wsdl:part name="parameters" element="ns:sayHello" />    
  24.   </wsdl:message>   
  25. - <wsdl:message name="sayHelloResponse">   
  26.   <wsdl:part name="parameters" element="ns:sayHelloResponse" />    
  27.   </wsdl:message>   
  28. - <wsdl:portType name="HelloServicePortType">   
  29. - <wsdl:operation name="sayHello">   
  30.   <wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello" />    
  31.   <wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse" />    
  32.   </wsdl:operation>   
  33.   </wsdl:portType>   
  34. - <wsdl:binding name="HelloServiceSoap11Binding" type="ns:HelloServicePortType">   
  35.   <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />    
  36. - <wsdl:operation name="sayHello">   
  37.   <soap:operation soapAction="urn:sayHello" style="document" />    
  38. - <wsdl:input>   
  39.   <soap:body use="literal" />    
  40.   </wsdl:input>   
  41. - <wsdl:output>   
  42.   <soap:body use="literal" />    
  43.   </wsdl:output>   
  44.   </wsdl:operation>   
  45.   </wsdl:binding>   
  46. - <wsdl:binding name="HelloServiceSoap12Binding" type="ns:HelloServicePortType">   
  47.   <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />    
  48. - <wsdl:operation name="sayHello">   
  49.   <soap12:operation soapAction="urn:sayHello" style="document" />    
  50. - <wsdl:input>   
  51.   <soap12:body use="literal" />    
  52.   </wsdl:input>   
  53. - <wsdl:output>   
  54.   <soap12:body use="literal" />    
  55.   </wsdl:output>   
  56.   </wsdl:operation>   
  57.   </wsdl:binding>   
  58. - <wsdl:binding name="HelloServiceHttpBinding" type="ns:HelloServicePortType">   
  59.   <http:binding verb="POST" />    
  60. - <wsdl:operation name="sayHello">   
  61.   <http:operation location="HelloService/sayHello" />    
  62. - <wsdl:input>   
  63.   <mime:content type="text/xml" part="sayHello" />    
  64.   </wsdl:input>   
  65. - <wsdl:output>   
  66.   <mime:content type="text/xml" part="sayHello" />    
  67.   </wsdl:output>   
  68.   </wsdl:operation>   
  69.   </wsdl:binding>   
  70. - <wsdl:service name="HelloService">   
  71. - <wsdl:port name="HelloServiceHttpSoap11Endpoint" binding="ns:HelloServiceSoap11Binding">   
  72.   <soap:address location="http://localhost:8081/TestAxis2Ws/services/HelloService.HelloServiceHttpSoap11Endpoint/" />    
  73.   </wsdl:port>   
  74. - <wsdl:port name="HelloServiceHttpSoap12Endpoint" binding="ns:HelloServiceSoap12Binding">   
  75.   <soap12:address location="http://localhost:8081/TestAxis2Ws/services/HelloService.HelloServiceHttpSoap12Endpoint/" />    
  76.   </wsdl:port>   
  77. - <wsdl:port name="HelloServiceHttpEndpoint" binding="ns:HelloServiceHttpBinding">   
  78.   <http:address location="http://localhost:8081/TestAxis2Ws/services/HelloService.HelloServiceHttpEndpoint/" />    
  79.   </wsdl:port>   
  80.   </wsdl:service>   
  81.   </wsdl:definitions>  
<?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>
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值