WSDL绑定是可选的吗?

时间:2014-03-04 11:14:08

标签: web-services soap wsdl

我有一个wsdl文件没有绑定部分:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<wsdl:definitions xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Engage" targetNamespace="http://tempuri.org/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/">
  <wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <xs:element name="OtherData">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="id" nillable="true" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="OtherDataResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="OtherDataResult" nillable="true" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="MyData">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="id" nillable="true" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="MyDataResponse">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="MyDataResult" nillable="true" type="xs:string" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">
      <xs:element name="anyType" nillable="true" type="xs:anyType" />
      <xs:element name="anyURI" nillable="true" type="xs:anyURI" />
      <xs:element name="base64Binary" nillable="true" type="xs:base64Binary" />
      <xs:element name="boolean" nillable="true" type="xs:boolean" />
      <xs:element name="byte" nillable="true" type="xs:byte" />
      <xs:element name="dateTime" nillable="true" type="xs:dateTime" />
      <xs:element name="decimal" nillable="true" type="xs:decimal" />
      <xs:element name="double" nillable="true" type="xs:double" />
      <xs:element name="float" nillable="true" type="xs:float" />
      <xs:element name="int" nillable="true" type="xs:int" />
      <xs:element name="long" nillable="true" type="xs:long" />
      <xs:element name="QName" nillable="true" type="xs:QName" />
      <xs:element name="short" nillable="true" type="xs:short" />
      <xs:element name="string" nillable="true" type="xs:string" />
      <xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" />
      <xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" />
      <xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" />
      <xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" />
      <xs:element name="char" nillable="true" type="tns:char" />
      <xs:simpleType name="char">
        <xs:restriction base="xs:int" />
      </xs:simpleType>
      <xs:element name="duration" nillable="true" type="tns:duration" />
      <xs:simpleType name="duration">
        <xs:restriction base="xs:duration">
          <xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" />
          <xs:minInclusive value="-P10675199DT2H48M5.4775808S" />
          <xs:maxInclusive value="P10675199DT2H48M5.4775807S" />
        </xs:restriction>
      </xs:simpleType>
      <xs:element name="guid" nillable="true" type="tns:guid" />
      <xs:simpleType name="guid">
        <xs:restriction base="xs:string">
          <xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" />
        </xs:restriction>
      </xs:simpleType>
      <xs:attribute name="FactoryType" type="xs:QName" />
      <xs:attribute name="Id" type="xs:ID" />
      <xs:attribute name="Ref" type="xs:IDREF" />
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="IMyService_OtherData_InputMessage">
    <wsdl:part element="tns:OtherData" name="parameters" />
  </wsdl:message>
  <wsdl:message name="IMyService_OtherData_OutputMessage">
    <wsdl:part element="tns:OtherDataResponse" name="parameters" />
  </wsdl:message>
  <wsdl:message name="IMyService_MyData_InputMessage">
    <wsdl:part element="tns:MyData" name="parameters" />
  </wsdl:message>
  <wsdl:message name="IMyService_MyData_OutputMessage">
    <wsdl:part element="tns:MyDataResponse" name="parameters" />
  </wsdl:message>
  <wsdl:portType name="IMyService">
    <wsdl:operation name="OtherData">
      <wsdl:input message="tns:IMyService_OtherData_InputMessage" wsaw:Action="http://tempuri.org/IMyService/OtherData" />
      <wsdl:output message="tns:IMyService_OtherData_OutputMessage" wsaw:Action="http://tempuri.org/IMyService/OtherDataResponse" />
    </wsdl:operation>
    <wsdl:operation name="MyData">
      <wsdl:input message="tns:IMyService_MyData_InputMessage" wsaw:Action="http://tempuri.org/IMyService/MyData" />
      <wsdl:output message="tns:IMyService_MyData_OutputMessage" wsaw:Action="http://tempuri.org/IMyService/MyDataResponse" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:service name="MyService">
    <wsdl:port name="xmlPort">
      <http:address location="http://localhost:59109/MyService.svc/xml" />
    </wsdl:port>
    <wsdl:port name="jsonPort">
      <http:address location="http://localhost:59109/MyService.svc/json" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

这个wsdl有效吗?或者换句话说,我们可以在没有绑定部分的情况下使用wsdl,或者它是必需的,这个wsdl是无效的吗?一些工具(如SoapUI)抛出异常但另一个(如此https://www.wsdl-analyzer.com/)表示这是有效的wsdl。

1 个答案:

答案 0 :(得分:0)

根据W3C note about WSDL 1.1

  

给定的portType

可能有任意数量的绑定

这是否意味着没有绑定? 好吧,看一下WSDL 1.1的XML模式, binding 元素根本就没有出现。

实际行为可能取决于SOAP库。请注意,绑定指定我们是否使用文档 RFC 样式调用以及是否对数据进行编码。