WSDL規則與樣本(1)

來源:互聯網
上載者:User

首先看看一段簡單的JAVA代碼,我們用它作為WSDL的服務實現代碼:
public class Test
{
  public String echo(String u){
    return "Hello " + u;
  }
}
然後看看用它匯出的WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://businessEngine.hongsoft.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://businessEngine.hongsoft.com-impl" xmlns:intf="http://businessEngine.hongsoft.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <wsdl:types/>//我們沒有自訂的類型

   <wsdl:message name="echoResponse">//返回的訊息

      <wsdl:part name="echoReturn" type="xsd:string"/>

   </wsdl:message>

   <wsdl:message name="echoRequest">//請求的訊息

      <wsdl:part name="u" type="xsd:string"/>

   </wsdl:message>

   <wsdl:portType name="Test">//一個portType可以看著一個類

      <wsdl:operation name="echo" parameterOrder="u">//一個operation就是一個方法

         <wsdl:input message="intf:echoRequest" name="echoRequest"/>

         <wsdl:output message="intf:echoResponse" name="echoResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="TestSoapBinding" type="intf:Test">
      //下面指定訊息封裝方式

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      //下面將WSDL描述與具體實現進行綁定,這裡採用SOAP方式

      <wsdl:operation name="echo">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="echoRequest">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://businessEngine.hongsoft.com" use="encoded"/>

         </wsdl:input>

         <wsdl:output name="echoResponse">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://businessEngine.hongsoft.com" use="encoded"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>
   //下面將發布的服務與前面的SOAP綁定進行關聯

   <wsdl:service name="TestService">

      <wsdl:port binding="intf:TestSoapBinding" name="Test">

         <wsdlsoap:address location="http://localhost:8080/hongsoft/services/Test"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.