日期:2012-09-06  浏览次数:20457 次

最后,我给出对应本节描述的save_category元素的Schema定义的Schema图示来结束本小节。

Figure 1.   SOAP API Schema图示



WSDL服务描述

对SOAP API消息完成Schema建模之后,一方面这个数据模型可以由SOAP Interface来使用,当发生具体调用时可以使用这个数据模型来除了传入的参数并生成传出的参数。同时,利用这个数据模型,我们可以生成相应的WSDL描述,从而将这个Web服务的接口文档发布给使用者,该接口文档是具备被程序自动处理的能力的。

以下是WSDL文档详细的定义:(完整的WSDL文档是: sagitta.wsdl)


<?xml version="1.0"?>
<definitions name="catalogService"
             targetNamespace="http://www.sagitta.com/wsdl/savecategory.wsdl"
             xmlns:tns="http://www.sagitta.com/wsdl/savecategory.wsdl"
             xmlns:myxs="http://www.sagitta.com/schema/"
             xmlns:soap="http://www.w3.org/2001/06/soap-envelope"
             xmlns="http://schemas.xmlsoap.org/wsdl/">

  <import namespace="http://www.sagitta.com/schema/" location=" http://www.sagitta.com/schema/save_category.xsd" />




这是WSDL文件的文件头,其中的import元素指明在这个WSDL文件中,types系统是由http://www.sagitta.com/schema/save_category.xsd文件具体描述,在这里仅仅是将其导入。


  <message name="save_category">
    <part name="body" element="myxs:save_category"/>
  </message>

  <message name="categoryList">
    <part name="body" element="myxs:categoryList"/>
  </message>




这里定义了两条消息:save_category消息,在前面的Schema建模中已经完整地创建了根元素的结构定义。其中myxs是这里使用的命名空间(namespace),命名空间的具体定义在文件头上出现。而categoryList将会对应save_category消息的返回消息,在Schema建模中没有表现,在这里我也仅列出一个元素名,相信大家在看了本文的前半部分以及本系列的前一篇文章之后,会很清楚如何来定义。


  <portType name="save_category_portType">
    <operation name="save_category_operation">
      <input message="tns:save_category"/>
      <output message="tns:categoryList"/>
    </operation>
  </portType>




这部分定义了服务访问点的调用模式的类型,表明这个入口类型是请求/响应模式,请求消息是save_category,而响应消息是categoryList。


  <binding name="save_category_soapBinding" type=" save_category_portType ">
    <soap:binding style="document" transport=" http://www.w3.org/2001/06/soap-envelope/http">
      <operation name="save_category_operation">
        <soap:operation soapAction=" http://www.sagitta.com/catalog/">
          <input>
            <soap:body use="literal" namespace=" http://www.sagitta.com/schema/"
                       encodingStyle=" http://www.w3.org/2001/06/soap-encoding"/>
          </input>
          <output>
            <soap:body use="literal" namespace=" http://www.sagitta.com/schema/"
                       encodingStyle=" http://www.w3.org/2001/06/soap-encoding"/>
          </output>
       &n