Through a customer survey program, Contoso learns that a significant number of their customers prefer to use the Optimized MIME Serialization (as defined in the MTOM specification) for sending and receiving messages. Contoso adds optional support for the Optimized MIME Serialization and expresses this optional behavior in a machine-readable form.
To indicate the use of optimization using the Optimized MIME
Serialization, Contoso uses the
mtom:OptimizedMimeSerialization
policy assertion (see the
example below).
Example 2-9. Optimized MIME Serialization Policy Assertion
<mtom:OptimizedMimeSerialization />
The
mtom:OptimizedMimeSerialization
element is a policy
assertion. (The prefix mtom
is used here to denote the Optimized MIME Serialization Policy
namespace.) This assertion identifies the use of MIME
Multipart/Related serialization for
as required for request and
response messages. Policy-aware clients
can recognize this policy assertion and engage Optimized MIME
Serialization for messages. The semantics of this assertion are
reflected in messages: they use an optimized wire format (MIME
Multipart/Related serialization).
Like Contoso’s optional support for Optimized MIME Serialization,
there are behaviors that may be engaged (in contrast to must be
engaged) for a Web service interaction. A service provider will not
fault if these behaviors are not engaged. Policy assertions can be
marked optional to represent behaviors that may be engaged for an
interaction. A policy assertion is marked as optional using the
wsp:Optional
attribute.
Optional assertions represent the capabilities of the service
provider as opposed to the requirements of the service provider.
In the example below, the Optimized MIME Serialization policy
assertion is marked optional. This policy expression allows the use
of optimization and requires the use of addressing and one of
transport- or message-level security.
If a client sends an
optimized (MTOM) message, this will be indicated by characteristics
associated by using such an optimized message, including a wire
format that is a Multipart/Related message and a content-type header
of "application/xop+xml
"
for the outer package. In this case, the response message will also
be optimized, also having a Multipart/Related message and
content-type header of "application/xop+xml
".
Note that when optimized messages are used, the Multipart/Related
message can have a single part containing the primary SOAP envelope.
Example 2-10. Optional MIME Serialization, Addressing and Transport- OR Message-Level Security Policy Expression
<All> <mtom:OptimizedMimeSerialization wsp:Optional="true"/> <wsap:UsingAddressing /> <ExactlyOne> <sp:TransportBinding>…</sp:TransportBinding> <sp:AsymmetricBinding>…</sp:AsymmetricBinding> </ExactlyOne> </All>
Contoso is able to meet their customer needs by adding optional support for the Optimized MIME Serialization. An optional policy assertion represents a behavior that may be engaged.