7.5 Metadata Exchange
When we first introduced the concept of loose coupling in Chapter 3, we explained that the sole requirement for a service requestor to interact with a service provider acting as the ultimate receiver is that the service requestor be in possession of the service provider’s service description. The WSDL definition, along with any associated XSD schemas, provides the basic set of metadata required to send valid SOAP messages for consumption by the service provider.
Having just covered policies in the previous section, it is clear that, when used, policies add another important layer to the metadata stack. Using policies, our service requestor now can send SOAP messages that comply with both the WSDL interface requirements and the associated policy assertions.
Again, though, regardless of how much metadata a service makes available, the fact is that we still need to retrieve this information by either:
manually locating it by searching for published documents
manually requesting it by contacting the service provider entity (the service owner)
programmatically retrieving it via a public service registry
programmatically retrieving it by interacting with proprietary interfaces made available by the service provider entity
With the exception of using the public service registry, none of these options are particularly attractive or efficient. It would be ideal if we could simply send a standardized request such as, "give me all of the information I need to evaluate and interact with your service provider." This is exactly what metadata exchange accomplishes (Figure 7.22).
Figure 7.22 Metadata exchanges let service requestors ask what they want to know about service providers.
7.5.1 The WS-MetadataExchange Specification
This specification essentially allows for a service requestor to issue a standardized request message that asks for some or all of the meta information relating to a specific endpoint address.
In other words, if a service requestor knows where a service provider is located, it can use metadata exchange to request all service description documents that comprise the service contract by sending a metadata exchange request to the service provider.
Originally the WS-MetadataExchange specification specified the following three types of request messages:
Even though these represent the three most common types of meta information currently attached to Web services, the specification authors realized that future metadata documents would likely emerge. A subsequent revision therefore resulted in a single type of request message:
This message is further supplemented by the Get request message. Both are explained in the following sections.
7.5.2 Get Metadata Request and Response Messages
As previously mentioned, a service requestor can use metadata exchange to programmatically request available metadata documents associated with a Web service. To do so, it must issue a Get Metadata request message. This kicks off a standardized request and response MEP resulting in the delivery of a Get Metadata response message.
Here’s what happens for a metadata retrieval activity to successfully complete:
A service requestor issues the Get Metadata request message. This message can request a specific type of service description document (WSDL, XSD schema, policy), or it can simply request that all available metadata be delivered.
The Get Metadata request message is received at the endpoint to which it is delivered. The requested meta information is documented in a Get Metadata response message.
The Get Metadata response message is delivered to the service requestor. The contents of this message can consist of the actual metadata documents, address references to the documents, or a combination of both.
Figure 7.23 illustrates these steps.
Figure 7.23 Contents of a sample Get Metadata response message.
7.5.3 Get Request and Response Messages
In Step 3 of the preceding scenario, we explained how the Get Metadata response message does not need to actually contain all of the requested metadata. It can simply provide a list of URIs that point to the separate documents.
To allow the retrieval of all meta information to be fully automated, the WS-MetadataExchange specification provides a means for the service requestor to explicitly request the document content for any references that were provided as part of the original Get Metadata response message. It achieves this through the use of the Get request and Get response messages.
Here’s a brief description of the steps involved in this sub-process:
Upon receiving the Get Metadata response message, the service requestor determines that it would like to receive the actual content of the metadata documents for which it only received references. As a result, the service requestor issues a Get request message indicating which metadata information it would like retrieved.
The Get request message is received at the endpoint to which it was delivered. The requested data is placed into a Get response message.
The Get response message is delivered to the service requestor.
Figure 7.24 shows the execution sequence of these steps, which should provide the service requestor with all the information it needs (and therefore concludes the metadata exchange process).
Figure 7.24 Contents of a sample Get response message.
7.5.4 Selective Retrieval of Metadata
Meta documents describing services with comprehensive interfaces and features can be large in size, especially when assembled into one mega-description. Use of the selective Get request message type therefore reduces the chances of unnecessary information being transported.
The Get Metadata response message first sends along what is considered the essential piece of service meta information. It is then up to the service requestor to determine what further metadata it requires. (Note that the endpoint to which a Get Metadata request message is sent can represent multiple WSDL, XSD schema, and policy documents.)
7.5.5 Metadata Exchange and Service Description Discovery
It also is important to note that metadata exchange does not really help service requestors discover service providers. Service registries, such as those implemented using the UDDI standard, can be used to discover service descriptions that meet certain search criteria. While service registries also provide location information for the actual WSDL definition of a service, they can be used in conjunction with metadata exchange messages.
Essentially, a service requestor could first query a public registry to retrieve the endpoint addresses of any Web service candidates that appear to provide the sought-after features. The same requestor could then employ metadata exchange to contact each candidate and request associated metadata documents. This would give the service requestor more information to better assess which service provider it should be working with. It also would provide the service requestor with all of the details it needs to begin interacting with the chosen service. So while it may not further the cause of attaining discoverable services, it does support discovery by rounding out the overall dynamic discovery process.
7.5.6 Metadata Exchange and Version Control
So far we’ve focused on the ability of metadata exchange to enable service requestors to retrieve any necessary meta information for them to begin interacting with service providers. Another important aspect of this WS-* extension is its potential to automate the administration of service contracts.
As services evolve, the nature and scope of the functionality they deliver can undergo alterations. This can result in changes trickling down to the service meta layer, which, in turn, can lead to new versions of a service’s WSDL, XSD schema, or policy documents.
This raises the age-old version control challenges. Service requestors already interacting with a service provider either need to be notified ahead of time of upcoming changes, or they need to be supported with an outdated service description.
Some services-based solutions have dealt with this problem by building custom operations that can be used to retrieve the latest service description (metadata) information. While the same functionality is essentially provided by metadata exchange, the main benefit of its use is that it implements this feature in a standardized manner. Now any service-oriented application that supports metadata exchange can allow service requestors to retrieve the latest service contract as often as they like.
When changes to meta information are expected to occur frequently, a service requestor could be programmed to periodically retrieve available metadata documents to compare them to the documents already in use. In fact, service requestors could even build metadata exchange features into their exception handling. If a standard SOAP request is rejected by the service provider as a result of an interface, schema, or policy incompatibility error, the service requestor’s exception handling routine could respond by retrieving and checking the latest metadata documents.
7.5.7 Metadata Exchange and SOA
The simple concepts behind metadata exchange support some key aspects of SOA (Figure 7.25). Its ability to automate the retrieval of meta information reinforces loose coupling between services, and increases the ability for service requestors to learn more about available service providers. By standardizing access to and retrieval of metadata, service requestors can programmatically query a multitude of candidate providers. Because enough service provider metadata can more easily be retrieved and evaluated, the overall discovery process is improved, and the likelihood for services to be reused is increased.
By establishing a standardized means of service description exchange, this extension can vastly improve interoperability when broadly applied to volatile environments. By being able to query service providers prior to attempting access, requestors can verify that the correct metadata is in fact being used for their planned message exchanges. This can increase the QoS factor of SOA, as it tends to avoid a multitude of maintenance problems associated with service contract changes.
Figure 7.25 Metadata exchange relating to other parts of SOA.
It is also worth mentioning that metadata exchange reduces the need for developers to attain meta information at design time and eliminates the need for custom-developed metadata retrieval extensions. Finally, the dynamic exchange of service descriptions can lead to the potential of automating version control and other metadata-related functions.
Figure 7.26 The revised RailCo Invoice Submission Process now includes a periodic metadata exchange with TLS.
SUMMARY OF KEY POINTS
Metadata exchange allows service requestors to issue request messages to retrieve metadata for service providers.
The WS-MetadataExchange specification standardizes two types of request messages: the Get Metadata request (which returns metadata content and/or references) and the Get request (which returns the content of a previously returned reference).
Metadata exchange assists in improving the service description discovery process and in alleviating version control issues related to service meta information.
Automated metadata retrieval leads to several standardized improvements within SOA and reinforces the loosely coupled nature of autonomous services.