|
1. 我是用eclipse Helios 写了以下的java class。
- //WebService1.java
- package test;
- public class WebService1 {
- public class NumbersBean {
- public float num1;
- public float num2;
- }
-
- public float servSummation (NumbersBean nBean)
- {
- float ans = 0;
- try {
- ans = nBean.num1 + nBean.num2;
- } catch (Exception e) {
- }
- return ans;
- }
- }
复制代码
2. 之后我right click 以上的文件,点击Web Services/Create Web Service。Web service type 我选 Bottom up Java Web Service, 下面的两个图分别选Start service 和 No client。
3. 完成之后,我right click project folder at eclipse,点击Run As/ Run on server。从中再点击几个link,我就得到以下的wsdl file。
- //WebService1.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://test" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://test/xsd" 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://test">
- <wsdl:documentation>Please Type your service description here</wsdl:documentation>
- - <wsdl:types>
- - <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test/xsd">
- - <xs:complexType name="WebService1_NumbersBean">
- <xs:sequence />
- </xs:complexType>
- </xs:schema>
- - <xs:schema xmlns:ax22="http://test/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test">
- <xs:import namespace="http://test/xsd" />
- - <xs:element name="servSummation">
- - <xs:complexType>
- - <xs:sequence>
- <xs:element minOccurs="0" name="nBean" nillable="true" type="ax21:WebService1_NumbersBean" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- - <xs:element name="servSummationResponse">
- - <xs:complexType>
- - <xs:sequence>
- <xs:element minOccurs="0" name="return" type="xs:float" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:schema>
- </wsdl:types>
- - <wsdl:message name="servSummationRequest">
- <wsdl:part name="parameters" element="ns:servSummation" />
- </wsdl:message>
- - <wsdl:message name="servSummationResponse">
- <wsdl:part name="parameters" element="ns:servSummationResponse" />
- </wsdl:message>
- - <wsdl:portType name="WebService1PortType">
- - <wsdl:operation name="servSummation">
- <wsdl:input message="ns:servSummationRequest" wsaw:Action="urn:servSummation" />
- <wsdl:output message="ns:servSummationResponse" wsaw:Action="urn:servSummationResponse" />
- </wsdl:operation>
- </wsdl:portType>
- - <wsdl:binding name="WebService1Soap11Binding" type="ns:WebService1PortType">
- <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- - <wsdl:operation name="servSummation">
- <soap:operation soapAction="urn:servSummation" 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="WebService1Soap12Binding" type="ns:WebService1PortType">
- <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- - <wsdl:operation name="servSummation">
- <soap12:operation soapAction="urn:servSummation" 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="WebService1HttpBinding" type="ns:WebService1PortType">
- <http:binding verb="POST" />
- - <wsdl:operation name="servSummation">
- <http:operation location="servSummation" />
- - <wsdl:input>
- <mime:content type="text/xml" part="parameters" />
- </wsdl:input>
- - <wsdl:output>
- <mime:content type="text/xml" part="parameters" />
- </wsdl:output>
- </wsdl:operation>
- </wsdl:binding>
- - <wsdl:service name="WebService1">
- - <wsdl:port name="WebService1HttpSoap11Endpoint" binding="ns:WebService1Soap11Binding">
- <soap:address location="http://localhost:8081/TestJavaWebService/services/WebService1.WebService1HttpSoap11Endpoint/" />
- </wsdl:port>
- - <wsdl:port name="WebService1HttpSoap12Endpoint" binding="ns:WebService1Soap12Binding">
- <soap12:address location="http://localhost:8081/TestJavaWebService/services/WebService1.WebService1HttpSoap12Endpoint/" />
- </wsdl:port>
- - <wsdl:port name="WebService1HttpEndpoint" binding="ns:WebService1HttpBinding">
- <http:address location="http://localhost:8081/TestJavaWebService/services/WebService1.WebService1HttpEndpoint/" />
- </wsdl:port>
- </wsdl:service>
- </wsdl:definitions>
复制代码
4. 我发现wsdl file里并没有num1和num2。那么我怎样pass in num1 和 num2 的数据呢?
希望能得到大大们的帮助,在下感激不尽了。 |