在Eclipse中使用Axis2插件自動生成WSDL文件

JDK版本:1.7update65java

Eclipse版本:Juno Service Release 2(4.2.2)apache

首先在Eclipse中安裝Axis2的插件:app

1,下載Axis2插件,最新版本爲1.6.2:http://www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.6.2/axis2-eclipse-codegen-plugin-1.6.2.zipeclipse

2,將zip壓縮包中的org.apache.axis2.eclipse.codegen.plugin_1.6.2.jar放置在%ECLIPSE_HOME%\plugins路徑下測試

3,重啓Eclipsespa

安裝完成後就能夠使用安裝好的插件生成WSDL文件了.net

1,建立一個普通的Java項目,在該項目下建立一個接口,在Navigator視圖下,項目結構以下:插件

package com.sean;  
  
public interface Math {  
    public int add(int a, int b);  
}

 

2,選擇Eclipse菜單欄中的File -> New -> Other...,在彈出的對話框中選擇Axis2 Code Generator,而後選擇Nextcode

3,而後選擇經過Java源文件生成WSDLorm

4,Fully Qualified Class name中填寫用來生成WSDL的Java類全名稱

而後經過Add Folder按鈕添加Java類編譯後生成的.class文件(Math.class)所在路徑

最後點擊Test Class Loading...按鈕

測試經過時(按鈕右側顯示Class file loaded successfully),纔可點擊Next按鈕

5,WSDL文件屬性值,這裏使用默認的便可

6,選擇將WSDL文件生成在本地文件系統,而且選擇好WSDL文件的生成路徑及文件名

點擊Finish後,將在指定位置生成WSDL文件(Math.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:wsaw="http://www.w3.org/2006/05/addressing/wsdl"   
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"   
    xmlns:xsd="http://sean.com"   
    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://sean.com">  
    <wsdl:types>  
        <xs:schema attributeFormDefault="qualified"   
            elementFormDefault="qualified"   
            targetNamespace="http://sean.com">  
            <xs:element name="add">  
                <xs:complexType>  
                    <xs:sequence>  
                        <xs:element minOccurs="0" name="args0" type="xs:int"/>  
                        <xs:element minOccurs="0" name="args1" type="xs:int"/>  
                    </xs:sequence>  
                </xs:complexType>  
            </xs:element>  
            <xs:element name="addResponse">  
                <xs:complexType>  
                    <xs:sequence>  
                        <xs:element minOccurs="0" name="return" type="xs:int"/>  
                    </xs:sequence>  
                </xs:complexType>  
            </xs:element>  
        </xs:schema>  
    </wsdl:types>  
    <wsdl:message name="addRequest">  
        <wsdl:part name="parameters" element="xsd:add"/>  
    </wsdl:message>  
    <wsdl:message name="addResponse">  
        <wsdl:part name="parameters" element="xsd:addResponse"/>  
    </wsdl:message>  
    <wsdl:portType name="MathPortType">  
        <wsdl:operation name="add">  
            <wsdl:input message="xsd:addRequest" wsaw:Action="urn:add"/>  
            <wsdl:output message="xsd:addResponse" wsaw:Action="urn:addResponse"/>  
        </wsdl:operation>  
    </wsdl:portType>  
    <wsdl:binding name="MathSoap11Binding" type="xsd:MathPortType">  
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>  
        <wsdl:operation name="add">  
            <soap:operation soapAction="urn:add" 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="MathSoap12Binding" type="xsd:MathPortType">  
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>  
        <wsdl:operation name="add">  
            <soap12:operation soapAction="urn:add" 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="MathHttpBinding" type="xsd:MathPortType">  
        <http:binding verb="POST"/>  
        <wsdl:operation name="add">  
            <http:operation location="add"/>  
            <wsdl:input>  
                <mime:content type="application/xml" part="parameters"/>  
            </wsdl:input>  
            <wsdl:output>  
                <mime:content type="application/xml" part="parameters"/>  
            </wsdl:output>  
        </wsdl:operation>  
    </wsdl:binding>  
    <wsdl:service name="Math">  
        <wsdl:port name="MathHttpSoap11Endpoint" binding="xsd:MathSoap11Binding">  
            <soap:address location="http://localhost:8080/axis2/services/Math"/>  
        </wsdl:port>  
        <wsdl:port name="MathHttpSoap12Endpoint" binding="xsd:MathSoap12Binding">  
            <soap12:address location="http://localhost:8080/axis2/services/Math"/>  
        </wsdl:port>  
        <wsdl:port name="MathHttpEndpoint" binding="xsd:MathHttpBinding">  
            <http:address location="http://localhost:8080/axis2/services/Math"/>  
        </wsdl:port>  
    </wsdl:service>  
</wsdl:definitions>
相關文章
相關標籤/搜索