WSDL - 理解消息定义

时间:2013-09-20 18:29:28

标签: wsdl

我正在尝试了解 wsdl 定义的结构,查看找到的示例here

我收到了serviceportTypeoperation部分,这是我在“阅读”规范时遇到问题的消息。

所以,只关注一条消息(multiply),而忽略其余的消息,我看到的结构如下:

<wsdl:definitions..>
  <wsdl:types>
    <xsd:schema>

      <xsd:element name="multiply" type="tns:multiply"/>
      <xsd:complexType name="multiply">
          ...
      </xsd:complexType>

     </xsd:schema>
   </wsdl:types>
   ...
   <wsdl:message name="multiply">
      <wsdl:part element="tns:multiply" name="parameters"/>
   </wsdl:message>
   ...
   <wsdl:portType>
   ...
   </wsdl:portType> 
   <wsdl:service>
   ...
   </wsdl:service>
</wsdl:definitions>

任何人都可以提供一个解释multiply是什么的句子,从以下开始:“multiply是一条消息......”?? ??

此外,有人可以解释我们有多少名称“乘法”吗?我认为有多个,我们似乎通过使用XML命名空间以及XML元素和类型的不同“命名空间”来避免冲突。

1 个答案:

答案 0 :(得分:1)

multiply是一条包含单个部分的消息,名为parameters,由单个元素tns:multiply组成。该元素的类型为tns:multiply

我使用XMLspy来填充这个例子:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
   xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:tns="http://new.webservice.namespace" targetNamespace="http://new.webservice.namespace">
    <wsdl:types>
        <xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified">
            <xs:complexType name="multiply">
                <xs:sequence>
                    <xs:element name="x" type="xs:int"/>
                    <xs:element name="y" type="xs:int"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="multiply" type="tns:multiply"/>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="multiply">
        <wsdl:part name="parameters" element="tns:multiply"/>
    </wsdl:message>
    <wsdl:portType name="NewPortType">
        <wsdl:operation name="NewOperation">
            <wsdl:input message="tns:multiply"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="NewBinding" type="tns:NewPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="NewOperation">
            <soap:operation soapAction="urn:#NewOperation"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="NewService">
        <wsdl:port name="NewPort" binding="tns:NewBinding">
            <soap:address location="No target address"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

这会导致以下SOAP请求:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <m:multiply xmlns:m="http://new.webservice.namespace">
            <m:x>0</m:x>
            <m:y>0</m:y>
        </m:multiply>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>