Java Reference
In-Depth Information
Hack the root element
You could define the root element in your schema to carry a version attribute of its own. This
would allow validation to be enforceable with tools, but this is not really a solution. The en-
forced validation requires additional and custom preprocessing. You do not want to pollute
your data model with implementation-specific items (such as a schema version number). This
is altogether inappropriate within web service usage.
Change the name or URI of the schema document
You could simply change the name of the file or its location. This would allow importing
schema documents or WSDLs to clearly represent what version they are using, as shown be-
low:
<customer
xmlns="http://www.soacookbook.com/Customer"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.soacookbook.com/Customer
http://www.soacookbook.com/Customer-v1.0.0.xsd">
This is similar to the previous choice. The schemaLocation attribute is not authoritative,
meaning that it is a hint to processors, and can be ignored. This would work for WSDL doc-
uments because they do explicitly import based on physical location. However, this could
create considerable inconsistencies and difficulties with tools because the namespace has not
changed, though the version has. That advertises to consumers that the WSDL is compatible
with the namespace in general, and not simply this specific version. Generated code used by
clients out in the world will be out of sync.
Use the namespace and document name
The best solution is to use the namespace itself to indicate the version of the schema. This is
familiar from many of the specifications we work with in web services. Consider the follow-
ing namespaces:
▪ The namespace for SOAP 1.2 is http://www.w3.org/2003/05/soap-envelope .
▪ The namespace for WS-Addressing 1.0 is http://www.w3.org/2005/08/addressing .
▪ The namespace for XML Schema 1.0 is http://www.w3.org/2001/XMLSchema , and it
uses the namespace for instances of http://www.w3.org/2001/XMLSchema-instance .
These namespaces, all of which are central to web services, indicate their version by including
the year and month of their publication in the namespace itself. There is no confusion as to
whether you are looking at a SOAP 1.1 or SOAP 1.2 envelope. However, you are not free to
simply replicate this structure directly in the schemas you define for use in a WSDL. That's
Search WWH ::




Custom Search