WSDL 要点总结

WSDL is used to specify the exact message format, Internet protocol, and address that a client must use to communicate with a particular Web service. In other words, a WSDL document tells us how to use a Web service. 

1.definitions

The definitions element usually contains several XML namespace declarations, which is normal for a root element. Among .Declaring the WSDL namespace as the default namespace avoids having to qualify every WSDL element explicitly, with a prefix.

The name attribute of definitions,which is used to name the entire WSDL document. In practice the WSDL name is not all that important. Nothing refers to it, and it's optional.

The targetNamespace attribute of The definitions , which identifies the namespace of elements defined in this WSDL document—much as it does in XML schema documents.The message, portType, and binding elements are assigned labels using their name attributes; these labels automatically take on the namespace specified by the targetNamespace attribute

2.types

The types element
uses the XML schema language to declare complex data types and elements that are used elsewhere in the WSDL document.

<!--A simple array-like type -->
<xsd:complexType name="IntArray">
<xsd:sequence>
<xsd:element name="arg" type="xsd:int" maxOccurs="unbounded"/> </xsd:sequence>
</xsd:complexType>


3
.import

The import element is similar to an import element in an XML schema document; it's used to import WSDL definitions from other WSDL documents.


4. message

The message element describes the message's payload using XML schema built-in types, complex types, or elements that are defined in the WSDL document's types element, or defined in an external WSDL document the import element refers to.

RPC-style messaging  and document-style messaging
If you're using RPC-style messaging, the part elements must use the type attribute; if you're using document-style messaging, the part elements must use the element attribute.


5.portType and operation

The portType and operation elements describe a Web service's interface and define its methods. A portType and its operation elements are analogous to a Java interface and its method declarations. An operation element uses one or more message types to define its input and output payloads. 


6
.binding

The binding element assigns a portType and its operation elements to a particular protocol (for instance, SOAP 1.1) and encoding style.

SOAP Binding

<definitions name="BookQuoteWS"
targetNamespace="http://www.Monson-Haefel.com/jwsbook/BookQuote"
xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote"
xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/">
...
</definitions>

The WSDL 1.1 namespace "http://schemas.xmlsoap.org/wsdl/" is the default
namespace of the WSDL document.
The transport  attribute of soapbind:binding is asssign protocal .Because HTTP is the only transport protocol allowed by J2EE Web Services,so  its value must be "http://schemas.xmlsoap.org/soap/http/".

The soapAction attribute of soapbind:operation elements dictates the value that must be placed in the SOAPAction header field of the HTTP request message.

RPC and Document-StyleIn

"rpc"-style messages, the namespace attribute must be specified with a valid URI.The URI can be the same as the targetNamespace of the WSDL document

<!-- binding tells us which protocols and encoding styles are used -->
<binding name="BookPrice_Binding" type="mh:BookQuote">
<soapbind:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getBookPrice">
<soapbind:operation style="rpc" soapAction="http://www.Monson-Haefel.com/jwsbook/BookQuote/GetBookPrice"/>
<input>
<soapbind:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote" />
 </input>
<output>
<soapbind:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote" />
</output>
</operation>
</binding>

A Document-Style Binding Doesn't Declare the namespace Attribute
<!-- binding tells us which protocols and encoding styles are used -->
<binding name="SubmitPurchaseOrder_Binding" type="mh:SubmitPurchaseOrder">
<soapbind:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="submit">
<soapbind:operation style="document"/>
<input>
<soapbind:body use="literal" />
</input>
<output>
<soapbind:body use="literal" />
</output>
</operation>
</binding>

Using the HTTP and MIME bindings
<!--HTTP/MIME-binding of BookQuote -->
<binding name="BookPrice_HttpMimeBinding" type="mh:BookQuote">
<http:binding verb="GET"/>
<operation name="getBookPrice">
<http:operation location="alt.http.service"/>
<input>
<http:urlEncoded/>
</input>
<output>
<mime:content type="text/html"/>
</output>
</operation>
</binding>


7.service and port

The service element is responsible for assigning an Internet address to a specific binding.The service element contains one or more port elements, each of which represents a different Web service. The port element assigns the URL to a specific binding.


8.
documentation

The documentation element explains some aspect of the WSDL document to human readers. Any of the other WSDL elements may contain documentation elements. The documentation element is not critical, so it will not be mentioned again in this chapter.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值