<xsd:complexType name="ArrayOfInt"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:int[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> |
<xsd:attribute name="arrayType" type="xsd:string"/> |
<xsd:complexType name="ArrayOfPERSON"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:PERSON[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> |
<?xml version="1.0" encoding="UTF-8" ?> <definitions … > <types> <schema targetNamespace="someNamespace" xmlns:typens="someNamespace" > <xsd:complexType name="PERSON"> <xsd:sequence> <xsd:element name="firstName" type="xsd:string"/> <xsd:element name="lastName" type="xsd:string"/> <xsd:element name="ageInYears" type="xsd:int"/> <xsd:element name="weightInLbs" type="xsd:float"/> <xsd:element name="heightInInches" type="xsd:float"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ArrayOfPERSON"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:PERSON[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> </schema> </types> <message name="addPersons"> <part name="person" type="typens:ArrayOfPERSON"/> </message> <message name="addPersonResponse"> <part name="result" type="xsd:int"/> </message> </definitions> |
<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); |
<?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> |