How to enable Fast Infoset
By sandoz on Mar 14, 2006
I have had a number of questions about how Fast Infoset can be enabled in JWSDP 1.6 and JWSDP 2.0. The answer is deceptively simple for developers even if the details (the devil is always in them) can quickly get somewhat complex, something i think i could have done better to highlight in the release notes.
The release notes for JWSDP 1.6 and JWSDP 2.0 contain links to Fast Infoset and how it can be used (see here and here respectively).
Enabling Fast Infoset requires no changes to WSDL and there are no changes to the JAX-RPC and JAX-WS APIs. It will work with any doc/lit, rcp/lit or even with rpc/encoded services. It will work with any statically or dynamically generated client side artifacts.
To enable Fast Infoset (in JAX-WS) one simply sets a property on the client side object obtained from the service as follows:
stubOrDispatch = ...; // Obtain reference to Stub or Dispatch
That is it! (for JAX-RPC it is almost identical, see the release notes for the differences).
How can that work?
Setting the CONTENT_NEGOTIATION_PROPERTY property to "pessimistic" will inform a JAX-WS client that it should add an HTTP Accept request-header field that includes a Fast Infoset MIME type when sending the HTTP request with the XML encoded SOAP message.
A service that is Fast Infoset enabled can look at the HTTP Accept request-header and if it includes a Fast Infoset MIME type the service can respond with Fast Infoset encoded SOAP message.
This is referred to as HTTP agent-driven negotiation.
When the client receives a Fast Infoset encoded SOAP message it knows the service can support Fast Infoset. So for any subsequent requests (for the life time of the stub) the client can encode using Fast Infoset. This is why the content negotiation is referred as "pessimistic", since the client pessimistically assumes on the first request that the service does not support Fast Infoset. The advantage of being pessimistic is that interoperability between XML-based Web services is supported while transparently accelerating those services that are Fast Infoset enabled.
By default all JWSDP 1.6 and JWSDP 2.0 services are Fast Infoset-enabled and so they are prepared to correctly process HTTP Accept request-headers and to also accept requests that are encoded using Fast Infoset.