标签:
首先创建一个web工程,创建过程如下:
如果选择Apache Tomcat v5.5,Dynamic web module version最高只能选择2.4,填写完成后点击“下一步”:
填写默认输出文件夹,填写完成后点击“下一步”:
填写根目录,填写完成后点击“完成”:
工程创建完成后,编写服务接口:
- package com.sean.ws;
-
- public interface MathIntf {
- public int plus(int a, int b);
- }
然后编写服务接口实现类:
- package com.sean.ws;
-
- public class MathImpl implements MathIntf {
- public int plus(int a, int b) {
- return a + b;
- }
- }
然后在服务接口实现类的基础上自动生成服务接口WSDL文件:
服务器选择Tomcat 6.0,Web Service环境选择Apache Axis(可选项还包含Axis2和CXF,不过这两项在使用前要预先设置),服务工程选择前面创建的ws_create工程,选择完成后点击“下一步”:
这里可以修改生成的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>
使用Eclipse自带的Axis1插件生成WSDL文件
标签:
原文地址:http://www.cnblogs.com/hujihon/p/5244355.html