wsdl詳細說明

<!- 
整個wsdl就相當於在定義一個類,types是導入包,message是定義private參數,portType是定義具體的接口,binding是實現接口,service是公佈方法讓別人調用

第一部分一些聲明 
1、wsdl的頂級元素爲definitions
2、xmlns:xsd="http://www.w3.org/2001/XMLSchema -->>定義命名空間,這個wsdl的系統元素(xsd:schema)全部屬於這個命名空間,xmlns即是xml namespace,後面的:xsd告訴大家這個命名空間的前綴是xsd,以後要使用這個命名空間裏面的元素就得加xsd,如下面引入xsd文件的時候使用<xsd:schema> </xsd:schema>。當然命名空間就是相當於聲明不同的包,不同的範圍。
3、xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/ -- >>同上面一樣,凡是使用到這個命名空間的元素就得使用wsdl前綴開頭,如<wsdl:definitions></wsdl:definitions> 、<wsdl:types></wsdl:types>\<wsdl:message></wsdl:messgae>
4、xmlns:tns_domain="http://www.deppon.com/esb/inteface/domain/crm -->>下面類似的這種形式的命名空間都是我們自己定義,根據實際需求自定義,這個crm包含了到crm系統的命名空間的具體內容,下面有用得到(<wsdl:type></wsdl:type>中)
5、targetNamespace="http://www.deppon.com/foss/customerService -->>是本例的整個wsdl文檔的命名空間,也是自定義的。而這句:xmlns:tns="http://www.deppon.com/foss/customerService則是告訴我們本個wsdl文檔中定義的元素,引用時需要帶tns前綴。比如第5部分中的binding中需要引用第3部分中定義在本個wsdl中的QureyIsCustomerBlankOutRequest,則需要寫成tns:QureyIsCustomerBlankOutRequest。
6、name="CustomerService" -->>是代表整個wsdl,在下面的內容中用不到,直接用已經聲明的前綴tns代表整個wsdl
->
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:tns_header="http://www.deppon.com/esb/header
xmlns:tns_exception="http://www.deppon.com/esb/exception" 
xmlns:tns_domain="http://www.deppon.com/esb/inteface/domain/crm"
 xmlns:tns="http://www.deppon.com/foss/customerService"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
name="CustomerService" 
targetNamespace="http://www.deppon.com/foss/customerService">
<!-
   第二部分Types
1、
 ->
<wsdl:types>
<xsd:schema 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
<!-
    觀察下面的CRM_QUREY_ISCUSTOMERBLANKOUT.xsd,裏面無需引用到header、exception、customerservice、soap的東西,都可以把他們刪了
 ->
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:tns_header="http://www.deppon.com/esb/header"
xmlns:tns_exception="http://www.deppon.com/esb/exception" 
xmlns:tns_domain="http://www.deppon.com/esb/inteface/domain/crm"
xmlns:tns="http://www.deppon.com/foss/customerService" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
targetNamespace="http://www.deppon.com/esb/inteface/domain/crm">
<!-
    引入CRM_QUREY_ISCUSTOMERBLANKOUT.xsd規範定義,還可以直接把schema定義到本個wsdl中,但是爲了看起來不是那麼複雜,我們還是在外面定義之後在引入
 ->
<xsd:include schemaLocation="http://192.168.17.141:17080/esb2/ws/crm2foss/customerService?xsd=CRM_QUREY_ISCUSTOMERBLANKOUT.xsd"/>
</xsd:schema>


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns_header="http://www.deppon.com/esb/header"
targetNamespace="http://www.deppon.com/esb/header">
<!-
    引入ESBHeader.xsd規範定義
 ->
<xsd:include schemaLocation="http://192.168.17.141:17080/esb2/ws/crm2foss/customerService?xsd=ESBHeader.xsd"/>
</xsd:schema>


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:tns_exception="http://www.deppon.com/esb/exception" 
targetNamespace="http://www.deppon.com/esb/exception">
<!-
    引入CommonException.xsd規範定義
 ->
<xsd:include schemaLocation="http://192.168.17.141:17080/esb2/ws/crm2foss/customerService?xsd=CommonException.xsd"/>
</xsd:schema>
</wsdl:types>

<!- 
  第三部分message 
  相當於定義一個方法的參數,傳入參數和傳出參數
  QureyIsCustomerBlankOutRequest:傳入參數,tns:domain是在最開始的元素definitions中聲明的,在types中引入的xsd文件的targetnamespace。
  所以tns:QureyIsCustomerBlankOutRequest來自於CRM_QUREY_ISCUSTOMERBLANKOUT.xsd中定義,同          理tns_domain:isCustomerBlankOutResponse、tns_header:esbHeader也是來自對應的xsd文件。
->
<wsdl:message name="QureyIsCustomerBlankOutRequest">
<wsdl:part element="tns_domain:isCustomerBlankOutRequest" name="request"></wsdl:part>
<wsdl:part element="tns_header:esbHeader" name="esbHeader"></wsdl:part>
</wsdl:message>
<wsdl:message name="QureyIsCustomerBlankOutResponse">
<wsdl:part element="tns_domain:isCustomerBlankOutResponse" name="response"></wsdl:part>
<wsdl:part element="tns_header:esbHeader" name="esbHeader"></wsdl:part>
</wsdl:message>
<wsdl:message name="ESBHeader">
<wsdl:part element="tns_header:esbHeader" name="header"></wsdl:part>
</wsdl:message>
<!- 
  第四部分portType 
  相當於定義接口
  定義一個QureyIsCustomeBlankOut接口,傳入參數tns:QureyIsCustomerBlankOutRequest是依賴message中定義的參數;
  傳出參數tns:QureyIsCustomerBlankOutResponse是依賴message中定義的參數;同理
->
<wsdl:portType name="CustomerService">
<wsdl:operation name="QureyIsCustomeBlankOut">
<wsdl:input message="tns:QureyIsCustomerBlankOutRequest"></wsdl:input>
<wsdl:output message="tns:QureyIsCustomerBlankOutResponse"></wsdl:output>
<wsdl:fault message="tns:CommonException" name="exception"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<!- 
  第五部分binding 
  相當於接口的具體實現
  
->
<wsdl:binding name="CustomerServiceSOAP" type="tns:CustomerService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="QureyIsCustomeBlankOut">
<soap:operation soapAction="http://www.deppon.com/foss/customerService/QureyIsCustomeBlankOut"/>
<wsdl:input>
<soap:header message="tns:QureyIsCustomerBlankOutRequest" part="esbHeader" use="literal"></soap:header>
<soap:body parts="request" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:header message="tns:QureyIsCustomerBlankOutResponse" part="esbHeader" use="literal"></soap:header>
<soap:body parts="response"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!- 
  第六部分service
  相當於發佈方法讓別人調用
 ->
<wsdl:service name="CustomerService">
<wsdl:port binding="tns:CustomerServiceSOAP" name="CustomerServiceSOAP">
<soap:address location="http://192.168.17.141:17080/esb2/ws/crm2foss/customerService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


下面是CRM_QUREY_ISCUSTOMERBLANKOUT.xsd,查詢客戶是否可作廢 接口的schema定義
================================================================================================================================
<schema xmlns:tns="http://www.deppon.com/esb/inteface/domain/crm" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"targetNamespace="http://www.deppon.com/esb/inteface/domain/crm">
<!-- 查詢客戶是否可作廢 -->
<element name="isCustomerBlankOutRequest" type="tns:IsCustomerBlankOutRequest"/>
<element name="isCustomerBlankOutResponse" type="tns:IsCustomerBlankOutResponse"/>
<complexType name="IsCustomerBlankOutRequest">
<annotation>
<documentation>傳入的查詢參數</documentation>
</annotation>
<sequence>
<element maxOccurs="unbounded" minOccurs="1" name="customerCodeList" type="string">
<annotation>
<documentation>客戶編碼列表</documentation>
</annotation>
</element>
</sequence>
</complexType>
<complexType name="IsCustomerBlankOutResponse">
<annotation>
<documentation>客戶是否允許作廢信息列表</documentation>
</annotation>
<sequence>
<element maxOccurs="unbounded" minOccurs="1" name="resultInfoList" type="tns:IsCustomerBlankOutList"></element>
</sequence>
</complexType>
<complexType name="IsCustomerBlankOutList">
<sequence>
<element maxOccurs="1" minOccurs="1" name="customerCode" type="string">
<annotation>
<documentation>客戶編碼</documentation>
</annotation>
</element>
<element maxOccurs="1" minOccurs="1" name="IsCustomerBlankOut" type="boolean">
<annotation>
<documentation>客戶是否可作廢標誌</documentation>
</annotation>
</element>
</sequence>
</complexType>
</schema>

下面是CommonException.xsd,通用異常信息的schema定義
================================================================================================================================
<schema xmlns:tns="http://www.deppon.com/esb/exception" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"targetNamespace="http://www.deppon.com/esb/exception">
<complexType name="CommonExceptionInfo">
<sequence>
<element maxOccurs="1" minOccurs="1" name="exceptioncode" type="string">
<annotation>
<documentation>
異常的編碼,ESB本身產生的異常編碼格式爲:ESB+nnnnnn,例如:ESB000001表示服務編碼不存在
</documentation>
</annotation>
</element>
<element maxOccurs="1" minOccurs="1" name="exceptiontype" type="string">
<annotation>
<documentation>
異常的類型,默認是業務異常:SystemException(系統異常)、BusinessException(業務異常)
</documentation>
</annotation>
</element>
<element maxOccurs="1" minOccurs="1" name="message" type="string">
<annotation>
<documentation>異常消息,用於顯示給最終用戶</documentation>
</annotation>
</element>
<element maxOccurs="1" minOccurs="1" name="createdTime" type="dateTime">
<annotation>
<documentation>異常發生時間</documentation>
</annotation>
</element>
<element maxOccurs="1" minOccurs="1" name="detailedInfo" type="string">
<annotation>
<documentation>異常的詳細消息,用於系統管理員診斷</documentation>
</annotation>
</element>
</sequence>
</complexType>
<element name="commonExceptionInfo" type="tns:CommonExceptionInfo"/>
</schema>

ESBHeader.xsd略


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章