<portType>和<operation>元素

  PortType定义了一些抽象的操作。PortType中的operation元素定义了调用PortType中所有方法的语法,每一个operation元素声明了方法的名称、参数(使用<message>元素)和各自的类型(<part>元素要在所有<message>中声明)。

  在一篇WSDL文档中可以有几个<PortType>元素,每一个都和一些相关操作放在一起,就和COM和一组操作的接口相似。

  在<operation>元素中,可能会有至多一个<input>元素,一个<output>元素,以及一个<fault>元素。三个元素各有一个名字和一个消息属性。

  <input>, <output>, <fault>元素属性的名字有何含义呢?它们可以用来区别两个同名操作(重载)。例如,看下面两个C函数:

void foo(int arg);
void foo(string arg);

  这种重载在WSDL中可以这样表示:

<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="fooDescription"
 targetNamespace="http://tempuri.org/wsdl/"
 xmlns:wsdlns="http://tempuri.org/wsdl/"
 xmlns:typens="http://tempuri.org/xsd"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-
 extension"
 xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="http://tempuri.org/xsd"
 xmlns="http://www.w3.org/2001/XMLSchema"
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
 elementFormDefault="qualified" >
</schema>
</types>

<message name="foo1">
 <part name="arg" type="xsd:int"/>
</message>

<message name="foo2">
 <part name="arg" type="xsd:string"/>
</message>

<portType name="fooSamplePortType">
<operation name="foo" parameterOrder="arg " >
 <input name="foo1" message="wsdlns:foo1"/>
</operation>
<operation name="foo" parameterOrder="arg " >
 <input name="foo2" message="wsdlns:foo2"/>
</operation>
</portType>

<binding name="fooSampleBinding" type="wsdlns:fooSamplePortType">
<stk:binding preferredEncoding="UTF-8" />
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="foo">
<soap:operation soapAction="http://tempuri.org/action/foo1"/>
 <input name="foo1">
  <soap:body use="encoded" namespace="http://tempuri.org/message/"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
 </input>
</operation>
<operation name="foo">
<soap:operation soapAction="http://tempuri.org/action/foo2"/>
<input name="foo2">
<soap:body use="encoded"
   namespace="http://tempuri.org/message/"
   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
</input>
</operation>
</binding>

<service name="FOOService">
<port name="fooSamplePort" binding="fooSampleBinding">
<soap:address
  location="http://carlos:8080/fooService/foo.asp"/>
</port>
</service>
</definitions>

  到目前为止,还没有一种SOAP的实现支持重载。这对基于JAVA的客户端十分重要,因为JAVA服务器使用的接口用到JAVA的重载特性。而对基于COM的客户端,就不那么重要,因为COM是不支持重载的。

相关文章:

  • 2021-12-08
  • 2021-07-08
  • 2021-04-23
  • 2021-11-16
  • 2022-01-21
猜你喜欢
  • 2021-11-26
  • 2021-11-13
  • 2021-07-05
  • 2022-02-13
  • 2021-12-30
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案