SOAP WSDL的XSD信息是强制性的吗?

时间:2018-11-13 16:37:37

标签: python xml soap xsd wsdl

SOAP WSDL是否必须使用XSD文件?如果.xsd文件不是强制性的,那么我将XSD信息放入WSDL Types元素中是强制性的吗?

我已经编写了一个自定义XML反序列化器/序列化器和一个自定义WSDL生成器,它们将采用python函数(已进行类型提示),并根据提供给它的函数动态生成WSDL。

 def example(arg1: str, arg2: int) -> str:
     code

因此,假设类型提示正确(无论编写了python模块等),我生成的WSDL是正确的。我可以输入一个或多个python函数,并动态生成WSDL。剩下的最后一块是类型标签。 XSD上的Wiki Blub使我认为制作XSD或XSD生成器将是微不足道的,因为它也基于功能类型提示,并且由于所有这些都是动态的/未知的,因此无法为XSD。

  

XSD可用于表示XML文档所遵循的一组规则   必须遵循以符合以下条件才能被视为“有效”   模式。但是,与大多数其他模式语言不同,XSD还是   旨在确定文件的有效性   将产生遵循特定数据的信息收集   类型。这样的验证后信息集可能对开发有用   XML文档处理软件。...

我看了几个示例WSDL,这个WSDL没有使用XSD,但是它明确说明了主要XML内的类型。我假设如果不使用XSD,我只需要在WSDL Types元素内添加信息?我已经掌握了这些信息,可以简单地将函数类型签名放入

<?xml version="1.0"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:hy="http://www.herongyang.com/Service/"
  targetNamespace="http://www.herongyang.com/Service/">

  <wsdl:documentation>
    Hello_WSDL_11_SOAP.wsdl
    Copyright (c) 2007 HerongYang.com, All Rights Reserved.
  </wsdl:documentation>

  <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.herongyang.com/Service/">
      <xsd:element name="HelloRequest" type="xsd:string"/>
      <xsd:element name="HelloResponse" type="xsd:string"/>
    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="helloInputMessage">
    <wsdl:part name="helloInputPart" element="hy:HelloRequest"/>
  </wsdl:message>
  <wsdl:message name="helloOutputMessage">
    <wsdl:part name="helloOutputPart" element="hy:HelloResponse"/>
  </wsdl:message>

  <wsdl:portType name="helloPortType">
    <wsdl:operation name="Hello">
      <wsdl:input name="helloInput"
        message="hy:helloInputMessage"/>
      <wsdl:output name="helloOutput"
        message="hy:helloOutputMessage"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="helloBinding" type="hy:helloPortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="Hello">
      <soap:operation
        soapAction="http://www.herongyang.com/Service/Hello"/>
      <wsdl:input name="helloInput">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="helloOutput">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="helloService">
    <wsdl:port name="helloPort" binding="hy:helloBinding">
      <soap:address
location="http://www.herongyang.com/Service/Hello_SOAP_11.php"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

编辑:这是另一个示例WSDL,它们的XSD用法也有所不同,只是xsd类型只是简单地添加到message元素中,而忽略了types元素。这种差异非常令人困惑,并且Google的任何信息都没有提供有关XSD特别是WSDL使用的任何具体信息。

<definitions name="SoapResponder"
             targetNamespace="http://www.SoapClient.com/xml/SoapResponder.wsdl">
<types>
    <schema targetNamespace="http://www.SoapClient.com/xml/SoapResponder.xsd">
    </schema>
</types>
<message name="Method1">
    <part name="bstrParam1" type="xsd:string"/>
    <part name="bstrParam2" type="xsd:string"/>
</message>
<message name="Method1Response">
    <part name="bstrReturn" type="xsd:string"/>
</message>
<portType name="SoapResponderPortType"></portType>
<binding name="SoapResponderBinding" type="tns:SoapResponderPortType">
    <soap:binding style="rpc"
                  transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="Method1">
        <soap:operation soapAction="http://www.SoapClient.com/SoapObject"/>
        <input>
            <soap:body use="encoded"
                       namespace="http://www.SoapClient.com/xml/SoapResponder.xsd"
                       encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
            <soap:body use="encoded"
                       namespace="http://www.SoapClient.com/xml/SoapResponder.xsd"
                       encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
    </operation>
</binding>
<service name="SoapResponder">
    <documentation>A SOAP service that echoes input parameters in the
        response
    </documentation>
    <port name="SoapResponderPortType" binding="tns:SoapResponderBinding">
        <soap:address
                location="http://www.soapclient.com/xml/soapresponder.wsdl"/>
    </port>
</service>
</definitions>

0 个答案:

没有答案