JDK版本:1.5.0_22java
Eclipse版本:Helios Service Release 2(3.6.2)ios
首先建立一個web工程,建立過程以下:web
若是選擇Apache Tomcat v5.5,Dynamic web module version最高只能選擇2.4,填寫完成後點擊「下一步」:apache
填寫默認輸出文件夾,填寫完成後點擊「下一步」:服務器
填寫根目錄,填寫完成後點擊「完成」:ui
工程建立完成後,編寫服務接口:spa
package com.sean.ws; public interface MathIntf { public int plus(int a, int b); }
而後編寫服務接口實現類:code
package com.sean.ws; public class MathImpl implements MathIntf { public int plus(int a, int b) { return a + b; } }
而後在服務接口實現類的基礎上自動生成服務接口WSDL文件:orm
服務器選擇Tomcat 6.0,Web Service環境選擇Apache Axis(可選項還包含Axis2和CXF,不過這兩項在使用前要預先設置),服務工程選擇前面建立的ws_create工程,選擇完成後點擊「下一步」:xml
這裏能夠修改生成的WSDL文件文件名、接口方法以及WSDL文件類型,選擇完成後點擊「下一步」:
只生成Web Service WSDL文件的話,不須要發佈接口(此時也不能發佈接口),這裏直接點擊「完成」便可
Web Service環境Apache Axis所需的jar包會自動放入WebRoot\WEB-INF\lib路徑下
而且在WebRoot\wsdl路徑下生成Web Service接口描述文件MathImpl.wsdl
接口部署文件將會生成在WebRoot\WEB-INF\MathImplService\com\sean\ws路徑下
Web Service WSDL文件內容以下(MathImpl.wsdl):
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://ws.sean.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://ws.sean.com" xmlns:intf="http://ws.sean.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)--> <wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://ws.sean.com" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="plus"> <complexType> <sequence> <element name="a" type="xsd:int"/> <element name="b" type="xsd:int"/> </sequence> </complexType> </element> <element name="plusResponse"> <complexType> <sequence> <element name="plusReturn" type="xsd:int"/> </sequence> </complexType> </element> </schema> </wsdl:types> <wsdl:message name="plusResponse"> <wsdl:part element="impl:plusResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="plusRequest"> <wsdl:part element="impl:plus" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:portType name="MathImpl"> <wsdl:operation name="plus"> <wsdl:input message="impl:plusRequest" name="plusRequest"> </wsdl:input> <wsdl:output message="impl:plusResponse" name="plusResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="MathImplSoapBinding" type="impl:MathImpl"> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="plus"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="plusRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="plusResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="MathImplService"> <wsdl:port binding="impl:MathImplSoapBinding" name="MathImpl"> <wsdlsoap:address location="http://localhost:8080/ws_create/services/MathImpl"/> </wsdl:port> </wsdl:service> </wsdl:definitions>