Documente Academic
Documente Profesional
Documente Cultură
DarkSwitch 2010
1. Introduction
WSDL is a document written in XML. The document describes a Web service. It specifies
the location of the service and the operations (or methods) the service exposes
2. WSDL Documents
It contains set of definitions to describe a web service
Elements of WSDL documents:
! <definitions>
! <types>
! ! definition of types ......
! </types>
! <message>
! ! definition of a message ....
! </message>
! <portType>
! ! definition of a port ...
! </portType>
! <binding>
! ! definition of a binding .....
! </binding>
!
! </definitions>
The <portType> element can be compared to a function library (or a module, or a class) in
a traditional programming language.
It describes a web service, the operations that can be performed, and the messages that
are involved.
The <types> element defines the data types that are used by the web service.
For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.
The <binding> element defines the message format and protocol details for each port.
2.5 An Example
! <message name=”getTermRequest”>
! ! <part name=”term” type=”xs:string”/>
! </message>
! <message name=”getTermResponse”>
! ! <part name=”value” type=”xs:string”/>
! </message>
! <portType name=”glossaryTerms”>
! ! <operation name=”getTerm”>
! ! ! <input message=”getTermRequest”/>
! ! ! <output message=”getTermResponse” />
! ! </operation>
! </portType>
3. Ports
A WSDL port describes the interfaces (legal operations) exposed by a web service:
• The operations that can be performed
• the message that are involved
Example:
! <message name=”newTermValues”>
! ! <part name=”term” type=”xs:string” />
! ! <part name=”value” type=”xs:string” />
! </message>
! <portType name=”glossaryTerms”>
! ! <operation name=”setTerm”>
! ! ! <input name=”newTerm” message=”newTermValues” />
! ! </operation>
! </portType>
In this example above, the port “glossaryTerms” defines a one-way operation called
“setTerm”
Itʼs one-way cause it just defined the input parameters, and no output is defined for the
operation.
Example:
! <message name=”getTermRequest”>
! ! <part name=”term” type=”xs:string” />
! </message>
! <message name=”getTermResponse”>
! ! <part name=”value” type=”xs:string” />
! </message>
! <portType name=”glossaryTerms”>
! ! <operation name=”getTerm”>
! ! ! <input message=”getTermRequest” />
! ! ! <output message=”getTermResponse” />
! ! </operation>
! </portType>
4. Binding
WSDL binding defines the message format and protocol details for a web service.
V 1.1 Last modification: 28/05/2010! Page 3
Programming Web Services - Lec. 4 WSDL! DarkSwitch 2010
Example:
! <message name=”getTermRequest”>
! ! <part name=”term” type=”xs:string” />
! </message>
! <message name=”getTermResponse”>
! ! <part name=”value” type=”xs:string” />
! </message>
! <portType name=”glossaryTerms”>
! ! <operation name=”getTerm”>
! ! ! <input message=”getTermRequest” />
! ! ! <output message=”getTermResponse” />
! ! </operation>
! </portType>
The soap:operation element defines each operation that the port exposes
for each operation the corresponding SOAP action has to be defined. You must also
specify how the input and output are encoded.
1. Policies
No part of WSDL natively describes things like security headers, reliable messaging
capabilities, and so on. To complete a well-defined service, you augment WSDL with extra
information.
Another reason to associate a WSDL with this extra information is to help the requestor
make an appropriate choice of service.
Youʼll also see policy assertions in security (e.g., digital signature in web service)
2. WS-Policy
• by URI
Syntaxis:
! <wsp:Policy ((Name=” ” TargetNamespace=” “?) | Id=” ”)>
! ! <policy specific assertion> *
! ! <policy-specific security> ?
! </wsp:Policy>
Policy assertions are normally added to the policy container as independent entities.
2.1.1 All
Example:
! <wsp:Policy name=”PolicyExample1”
! ! TargetNamespace=”http://ww.skatestown.com/policies” >
! ! <wsp:all>
! ! ! <Assertion:A />
! ! ! <Assertion:B />
! ! ! <Assertion:C />
! ! </wsp:all>
! </wsp:Policy>
2.1.2 ExactlyOne
Example:
! <wsp:Policy name=”PolicyExample2”
! ! TargetNamespace=”http://www.skatestown.com/policies” >
! ! <wsp:ExactlyOne>
! ! ! <Assertion: A />
! ! ! <Assertion:B />
! ! ! <Assertion:C />
V 1.1 Last modification: 28/05/2010! Page 6
Programming Web Services - Lec. 4 WSDL! DarkSwitch 2010
! ! </wsp:ExactlyOne>
! </wsp:Policy>
2.1.3 OneOrMore
The operator OneOrMore is a variation of the combination of ExactlyOne and ALL, where
some subset of the policy assertions listed as child element is in effect.
2.1.4 Others
The operators can nest. Any of the Assertion elements can be replaced by an operator.
2.2.1 Usage
The usage attribute describes how the policy assertion is to be interpreted in the context of
the policy.
2.2.2 Preference
The value of the Preference attribute is an integer value. The higher the number, the
stronger the preference.
Example:
! <wsp:Policy name=”PolicyExample3”
! ! TargetNamespace=”http://www.skatestown.com/policies” >
! ! <wsp:ExactlyOne>
! ! ! <Assertion:A wsp:Preference=”100” />
! ! ! <Assertion:B wsp:Preference=”50” />
! ! ! <Assertion:C wsp:Preference=”1” />
! ! </wsp:ExactlyOne>
! </wsp:Policy>
Suggest to the requestor that it has a choice of assertion A, B or C, and that the service
provider would much prefer the requestor to choose assertion A.
3. Referencing Policies
V 1.1 Last modification: 28/05/2010! Page 7
Programming Web Services - Lec. 4 WSDL! DarkSwitch 2010
WS-Policy defines an element called PolicyReference that allows you to include the
content of one policy into another.
The included policy element are wrapped with an ALL operator element and inserted in
place of the PolicyReference element.
Example:
! <ws:Policy name=”PolicyExample4”
! ! TargetNamespace=”http://www.skatestown.com/policies”
! ! xmlns:tns=”http://www.skatestown.com/policies” >
! ! <wsp: ExactlyOne>
! ! ! <wsp:PolicyReference Ref=”tns_PolicyExample2” />
! ! ! <Assertion:D />
! ! ! <Assertion:E />
! ! </wsp:ExactlyOne>
! </wsp:Policy>
is Equivalent to
! <wsp:Policy name=”PolicyExmaple4”
! ! TargetNamespace=”http://ww.skatestown.com/policies” >
! ! <wsp:ExactlyOne>
! ! ! <wsp:All>
! ! ! ! <wsp:ExactlyOne>
! ! ! ! ! <Assertion:A />
! ! ! ! ! <Assertion:B />
! ! ! ! ! <Assertion:C />
! ! ! ! </wsp:ExactlyOne>
! ! ! </wsp:All>
! ! ! <Assertion:D />
! ! ! <Assertion:E />
! ! </wsp:ExactlyOne>
! </wsp:Policy>
4. Policy Assertions
You choose from these standardized policy assertions, configure them, and combine them
into a policy document.
5. Policy Attachments
Example:
! <wsp:Policy name=”SkatestownLanguages”
! ! TargetNamespace=”http://www.skatestown.com/policies”>
! ! <wsp:OneOrMore>
! ! ! <wsp:Language Language=”en” />
! ! ! <wsp:Language Language=”es” />
! ! ! <wsp:Language Language=”fr” />
! ! </wsp:OneOrMore>
! </wsp:Policy>
In this example, the policy of the language expected with SkatesTownʼs services can be
English, Spanish, or French.
This policy could then be referenced from within the PriceCheck service declaration, using
a WS-PolicyAttachment attribute:
Example:
! <service name=”PriceCheck”
! ! wsp:PolicyRefs=”stp:SkatestownLanguages”
! ! xmlns:wsp=”http://schemas.xmlsoap.org/ws/2002/12/policy”
! ! xmlns:stp=”http://www.skatestown.com/policies” >
! ! <port name=”PriceCheck” binding=”pc:PriceCheckSOAPBinding”>
! ! ! <documentation>
! ! ! ! <wsi::Claim conformsTo=”http://ws-i.org/profiles/basic/1.0” />
! ! ! </documentation>
! ! ! <soap:address location=”http://www.skatestown.com/services/
PriceCheck” />
! ! </port>
! </service>
The policies can be inherited with a collection of WSDL elements. For example, a policy
attached to a portTYep would be inherited by its input, output, and fault child element.
The policyAttachment element is defined to allow you to express the attachment of one or
more policies to a policy subject.
1. Introduction
For serve services between the server and the client, there are still few questions:
V 1.1 Last modification: 28/05/2010! Page 9
Programming Web Services - Lec. 4 WSDL! DarkSwitch 2010
Additional elements:
• Documentation: Used to provide human-readable documentation and can be included
inside any other WSDL element
• import: Used to import other WSDL documents or XML Schemas.
3.1 Definitions
The root element of WSDL document
Contains all other WSDL element
3.2 Message
Each message element can be used as an input, output or fault message
All message element must have a unique name in the WSDL document
Example
! <message name=”PriceCheckResponse”>
! ! <part name=”result” element=”avail:StockAvailability” />
! </message>
In the message we can use element cause WSDL can use any type.
In this case, element=”avail:StockAvailability” is putted as the body of the message
Example2:
! <message name=”StockAvailableExpirationNotification”>
! ! <part name=”timeStamp” type=”xsd:timeInstant” />
! ! <part name=”correlationID” type=”reg:correlationID” />
! ! <part name=”items” type=”reg:ArrayOfItem” />
! ! <part name=”clientArg” type=”xsd:string” />
! </message>
3.3 portType
Describes an interface to a Web service
Typically a WSDL document contains a single portType
3.4 Operations
Defines a method on a Web service
Names should be different with the names of portTypes
Example:
! <portType name=”Hello_PortType”>
! ! <operation name=”sayHello”>
! ! ! <input message=”tns:SayHelloRequest” />
! ! ! <output message=”tns:SayHelloResponse” />
! ! </operation>
! </portType>
3.5 Binding
The binding element itself specifies name and type attributes.
The type attribute references the portType defined earlier in the document.
soap:binding: It specifies the style and the transport of the SOAP message
soap:operation: The binding of a specific operation to a specific SOAP implementation
soap:body: To specify the details of the input and output messages.
Example of soap:body
! <input>
! ! <soap:body use=”literal” />
! </input>
In this case, the use of literal will return the follow soap message:
</soapenv:Envelope>
3.6 Service
Specifies location of a service
Example:
! <service name=”Hello_Service”>
! ! <documentation>
! ! ! WSDL File for HelloService
! ! </documentation>
! ! <port binding=”Hello_Binding” name=”tns:Hello_PortType”>
! ! ! <soap:address location=”http://localhost:8080/soap/servlet/rcrouter”>
! ! </port>
! </service>
4. WSDL Extensions
We can use “get” operations of HTTP to get the URL
Example:
! <binding name=”priceCheckHTTPGetBinding” type=”pc:priceCheckPortType”>
! ! <http:binding verb=”GET” />
! ! <operation name=”checkPrice”>
! ! ! <http:operation location=”checkPrice” />
! ! ! <input>
! ! ! ! <http:urlEncoded/>
! ! ! </input>
! ! ! <output>
! ! ! ! <mime:content type=”text/xml” />
! ! ! </output>
! ! </operation>
! </binding>
http://www.skatetown.com/checkPrice?sku=xxx1234
Example:
! public interface PriceCheckPortType extends java.rmi.Remote {...}
Example:
! package com.skatestown.www.services.PriceCheck;
The signatura is built from operation name, input, output and fault element (faults are
included as exceptions)
Example:
! public com.skatestown.www.ns.avualability.AvailableType
! ! checkPrice(java.lang.String sku) throws java.rmi.RemoteException;
Binding generates a stub class. The name of binding will be uses as the name of the class;
the package will get from the targetNamespace of the definition element.
Example of assertion:
!
! <wsrm: DeliveryAssurances Value=”wsrm:ExactOnce” />
! <wsrm: Integrity wsp:Usage=”wsp:Required”>
! ....
! </wsrm:Integrity>
<wsp:Policy ...>
! <wsp: ExactlyOne>
! ! [<wsp:All> [ <assertion ...> ... </assertion> ] *
! ! </wsp:All> ]*
! </wsp:ExactlyOne>
</wsp:Policy>
Then, we can have some operations like Normalization, Merging and Intersection that
helps a document or documents to be normalized.
7.5.1 Normalization
Example:
! <wsp:Policy ...>
! ! <wsp:All>
! ! ! <wsp:ExactlyOne>
! ! ! ! <nsSecurityAssertion wsp:Optional=”true” />
! ! ! ! <nsReliableMessagingAssertion />
! ! ! </wsp:ExactlyOne>
! ! ! <nsTransactionAssertion />
! ! ! <nsAuditAssertion />
! ! </wsp:All>
! </wsp:Policy>
7.5.2 Merge
Example:
! Policy P1
! <wsp:Policy wsu:id="P1"...>
! ! <wsp:ExactlyOne>
! ! ! <wsp:All>
! ! ! ! <nsSecurityAssertion/>
! ! ! </wsp:All>
! ! ! <wsp:All>
! ! ! ! <nsReliableMessagingAssertion/>
! ! ! </wsp:All>
! ! </wsp:ExactlyOne>
! </wsp:Policy>
! Policy P2
! <wsp:Policy wsu:id=”P2” ...>
! ! <wsp:ExactlyOne>
! ! ! <wsp:All>
! ! ! ! <nsTransactionAssertion />
! ! ! </wsp:All>
! ! ! <wsp:All>
! ! ! ! <nsAuditAssertion />
! ! ! </wsp:All>
! ! </wsp:ExactlyOne>
! </wsp:Policy>
7.5.3 Intersection
Example:
Result:
! <wsp:All>
! ! <nsSecurityAssertion level=”high” />
! ! <nsSecurityAssertion />
! ! <nsReliableMessagingAssertion timeout=”100” />
! ! <nsReliableMessagingAssertion retries=”3” />
! ! <nsReliableMessagingAssertion />
! </wsp:All>
! <wsp:Policy ...>
! ! <wsp:ExactlyOne>
! ! ! <wsp:All />
! ! </wsp:ExactlyOne>
! </wsp:Policy>
! <wsp:Policy ...>
! ! <wsp:ExactlyOne />
! </wsp:Policy>
8.1 Interface
Interface replaces portType
Now the interface could be extended:
Example:
8.2 Operation
Example:
! <interface name=”PriceCheck”>
! ! <operation name=”checkPrice”
! ! ! style=”http://www.w3.org/2003/11/wsdl/in-out”>
! ! ! ....
! ! </operation>
! </interface>
Example:
! Using:
! <input message=”avail:sku” />
! instead of
! <input message=”pc:priceCheckRequest” />
! <message name=”PriceCheckRequest”>
! ! <part name=”result” element=”avail:sku” />
! <interface name=”PriceCheck”>
! ! <operation name=”checkPrice”
V 1.1 Last modification: 28/05/2010! Page 17
Programming Web Services - Lec. 4 WSDL! DarkSwitch 2010
! ! ! ! style=”http://www.w3.org/2003/11/wsdl/in-out” >
! ! ! <input message=”avail:sku” />
! ! ! <output message=”avail:StockAvailability” />
! ! </operation>
! </interface>
! ! !
8.3 Types
Clarifies contents of types as either XML schema element or XML import element
8.4 Binding
Replace SOAP 1.1 binding type with SOAP 1.2 type
The binding is also used to bind features and properties that are specified for an interface.
For example, if an interface specified that an authentication features is being used, a
binding can specify that this feature is realized by some form of Kerberos ticket that must
be presented as proof of identity of authenticate the requestor.
The binding of operations changed due to changes in operations at the interface level.
Example:
All endpoints (was port) child elements must refer (via binding) to the same interface
8.6 Definitions
The import in WSDL 1.1 now is divided into import and include.
The import element is used to import WSDL definitions from other WSDL namespaces.
The include element is used to include elements defined in import and include, but with
the same namespace.
! <interface name=”PriceCheck”>
! ! <operation name=”checkPrice”>
! ! ! style=”http://www.w3.org/2003/11/wsdl/in-out”>
! ! ! <input message=”avail:sku”/>
! ! ! <output message=”avail:StockAvailability”/>
! ! </operation>
! </interface>