Business Process Execution Language for Web Services 2nd Edition
上QQ阅读APP看书,第一时间看更新

WS-Addressing

Every web service has an endpoint to which service messages are targeted. WSDL allows you to define endpoints for the messages using port types, bindings, service elements, and so on. However, the WSDL 1.1 model lacks flexibility. (For detailed information on WSDL refer http://www.cos.ufrj.br/~baiao/papers/cavalcantim_workflow.pdf.)

To achieve flexibility, a new specification for defining endpoints has been proposed. This is known as WS-Addressing. This specification facilitates the following:

  • Endpoint descriptions may be dynamically generated and customized.
  • During stateful interactions, new service instances may be created. The new specifications help in identifying these.
  • Endpoint information may be shared between communicating parties in tightly coupled environments.

The specification defines new XML elements to address service endpoints. The following XML document illustrates the use of these new elements.

<S:Envelope xmlns:S=”http://www.w3.org/2002/12/soap-envelope”
  xmlns:wsa=”http://schemas.xmlsoap.org/ws/2003/03/addressing”>
<S:Header>
  <wsa:ReplyTo>
    <wsa:Address>
      http://...
    </wsa:Address>
  </wsa:ReplyTo>
  <wsa:To>
    http://...
  </wsa:To>
  <wsa:Action>
    http://...
  </wsa:Action>
</S:Header>
<S:Body>
...
</S:Body>
</S:Envelope>

The Header contains ReplyTo, To, and Action elements. The To element specifies the URI to which the message is sent and the ReplyTo element specifies the URI to which a reply should be sent. The Address element specifies the desired URI. The Action element specifies the desired action on the target.

Endpoint Reference

The definition for the endpoint reference is shown below:

<wsa:EndpointReference>
  <wsa:Address>
    xs:anyURI
  </wsa:Address>
  <wsa:ReferenceProperties> 
    ... 
  </wsa:ReferenceProperties> ?
  <wsa:PortType>
    xs:Qname
  </wsa:PortType> ?
  <wsa:ServiceName PortName=”xs:NCName”?>
    xs:Qname
  </wsa:ServiceName> ?
<wsp:Policy/> *
</wsa:EndpointReference>

The following elements are used in the definition:

  • Address: Mandatory element; specifies the address property of an endpoint reference. This may be a logical address or identifier for the endpoint.
  • ReferenceProperties: Optional element; may contain child elements that specify the reference properties of the reference.
  • PortType: Specifies the port type property of the endpoint reference.
  • ServiceName: Specifies the WSDL description of the endpoint. This is basically the <wsdl:service> element in the WSDL document.
  • PortName: Specifies the <wsdl:port> definition for the endpoint.
  • Policy: Specifies the policy for the current interaction.

With the addition of these new elements, the WS-Addressing endpoint specification overcomes the limitations of the WSDL 1.1 specification to provide the facilities discussed above.

The WS-Addressing specification takes the next-hop approach for routing. In the next-hop approach, only the single endpoint of an ultimate destination is stored. This is sufficient for the message sender and the message sender need not know the full message path to the destination. Each node in the path examines the destination endpoint address and forwards the message to the next node closer to the destination. As the message does not need to be modified on its way to the ultimate destination, message security is not compromised.

In WS-Addressing, the EndpointReference element defines the endpoint for the destination and the message source. Note that the wsa:from element also uses the same EndpointReference to specify the source location. The schema definition of the EndpointReferenceType is shown below:

<xs:complexType name=”EndpointReferenceType”> 
<xs:sequence> 
<xs:element name=”Address” type=”wsa:AttributedURI” />   
<xs:element name=”ReferenceProperties” type=”wsa:ReferencePropertiesType” 
minOccurs=”0” />   
<xs:element name=”PortType” type=”wsa:AttributedQName” minOccurs=”0” />
<xs:element name=”ServiceName” type=”wsa:ServiceNameType” minOccurs=”0” />
<xs:any namespace=”##other” processContents=”lax” minOccurs=”0” 
maxOccurs=”unbounded”/>   
</xs:sequence> 
<xs:anyAttribute namespace=”##other” processContents=”lax” />
</xs:complexType> 
<xs:element name=”EndpointReference” type=”wsa:EndpointReferenceType”/> ...   

The ReferenceProperties element allows you to specify additional information such as port name, service name, and policies, and is easily extensible. You can specify any number of additional custom properties.

Faults

During message transport, faults can occur along the message path. The fault element describes the reason for the fault. A typical fault element used in the path is shown below:

<m:fault>
  <m:code>812</m:code>
  <m:reason>Service Too Busy</m:reason>
  <m:retryAfter>300</m:retryAfter>
</m:fault>

The code element specifies the fault code. Codes starting with 8xx indicate receiver faults and those starting with 7xx indicate sender faults. The reason element describes the cause of the fault in string format and the retryAfter element states the retry time interval.