16 Optimizing XML Transmission Using Fast Infoset
- Overview of Fast Infoset
- Enabling Fast Infoset on Web Services
- Enabling and Configuring Fast Infoset on Web Services Clients
- Disabling Fast Infoset on Web Services and Clients
Parent topic: Developing Advanced Features of JAX-WS Web Services
Overview of Fast Infoset
Fast Infoset is a compressed binary encoding format that provides a more efficient serialization than the text-based XML format. Fast Infoset optimizes both document size and processing performance.
When enabled, Fast Infoset converts the XML Information Set in the SOAP envelope into a compressed binary format before transmitting the data. Fast Infoset optimizes encrypted and signed messages, MTOM-enabled messages, and SOAP attachments, and supports both HTTP and JMS transports.
The Fast Infoset specification, ITU-T Rec. X.891 and ISO/IEC 24824-1 (Fast Infoset) is defined by both the ITU-T and ISO standards bodies. The specification can be downloaded from the ITU Web site: http://www.itu.int/rec/T-REC-X.891-200505-I/en
The Fast Infoset capability is enabled on all web services, by default. For web service clients, Fast Infoset is enabled if it is enabled on the web service and advertised in the WSDL.
You can explicitly enable and configure Fast Infoset on a web service or client, as described in the following sections.
Parent topic: Optimizing XML Transmission Using Fast Infoset
Enabling Fast Infoset on Web Services
The Fast Infoset capability is enabled on a web service and advertised in the WSDL, by default. You can enable Fast Infoset explicitly on a web service as follows:
-
At design time, using
com.oracle.webservices.api.FastInfosetService
annotation, as shown in Example Using @FastInfosetService Annotation at Design Time.For more information about the annotation, see @FastInfosetService in Securing Web Services and Managing Policies with Oracle Web Services Manager.
-
Post-deployment, by attaching the
oracle/fast_infoset_service_policy
to the web service. For more information, see the following sections:-
Attaching Policies to Web Services and Clients Using Fusion Middleware Control in Securing Web Services and Managing Policies with Oracle Web Services Manager
-
Configuring Fast Infoset Using WLST in Administering Web Services
-
oracle/fast_infoset_service_policy in Securing Web Services and Managing Policies with Oracle Web Services Manager
-
Example Using @FastInfosetService Annotation at Design Time
The following code excerpt provides an example of using the com.oracle.webservices.api.FastInfosetService
annotation to enable and configure Fast Infoset on a web service at design time.
package examples.webservices.hello_world; import javax.jws.WebService; import com.oracle.webservices.api.FastInfosetService; @WebService(name="HelloWorldPortType", serviceName="HelloWorldService") @FastInfosetService(enabled=true) public class HelloWorldImpl { public String sayHelloWorld(String message) { try { System.out.println("sayHelloWorld:" + message); } catch (Exception ex) { ex.printStackTrace(); } return "Message from FI Enabled Service: '" + message + "'"; } }
Parent topic: Optimizing XML Transmission Using Fast Infoset
Enabling and Configuring Fast Infoset on Web Services Clients
You can explicitly enable and configure Fast Infoset on a web service client as follows:
-
At design time, using
com.oracle.webservices.api.FastInfosetClientFeature
feature class, as shown in Example Using FastInfosetClientFeature Feature Class at Design Time.-
com.oracle.webservices.api.FastInfosetClient
annotation, as shown in Example Using @FastInfosetClient Annotation at Design Time.For more information about the annotation, see @FastInfosetService in Securing Web Services and Managing Policies with Oracle Web Services Manager.
-
com.oracle.webservices.api.FastInfosetClientFeature
feature class, as shown in Example Using FastInfosetClientFeature Feature Class at Design Time.
-
-
Post-deployment, by attaching
oracle/fast_infoset_client_policy
to the web service. For more information, see the following sections:-
Attaching Policies to Web Services and Clients Using Fusion Middleware Control in Securing Web Services and Managing Policies with Oracle Web Services Manager
-
Configuring Fast Infoset Using WLST in Administering Web Services
-
oracle/fast_infoset_client_policy in Securing Web Services and Managing Policies with Oracle Web Services Manager
-
- Configuring the Content Negotiation Strategy
- Example Using @FastInfosetClient Annotation at Design Time
- Example Using FastInfosetClientFeature Feature Class at Design Time
Parent topic: Optimizing XML Transmission Using Fast Infoset
Configuring the Content Negotiation Strategy
When enabling Fast Infoset on the client, you can configure the content negotiation policy. Table 16-1 summarizes the valid content negotiation strategies defined by com.oracle.webservices.api.FastInfosetContentNegotiationType
.
Table 16-1 Content Negotiation Strategy
Value | Description |
---|---|
|
Assumes that Fast Infoset is enabled on the service. All requests will be sent using Fast Infoset. |
|
Initial request from client is sent without Fast Infoset enabled, but with an HTTP Accept header that indicates that the client supports the Fast Infoset capability. If the service response is in Fast Infoset format, confirming that Fast Infoset is enabled on the service, then subsequent requests from the client will be sent in Fast Infoset format. |
|
Client requests will not use Fast Infoset. |
Please note:
-
If the content negotiation strategy is configured explicitly on the client:
-
It takes precedence over the negotiation strategy advertised in the WSDL.
-
If the configured content negotiation strategy conflicts with the capabilities advertised by the service (for example, if the client configures
OPTIMISTIC
and the service has Fast Infoset disabled), then an exception is generated.
-
-
If the content negotiation strategy is not configured explicitly by the client:
-
If Fast Infoset is enabled and advertised on the service, the
OPTIMISTIC
content negotiation strategy is used. -
If Fast Infoset is disabled and not advertised on the service, the
NONE
content negotiation strategy is used.
-
Example Using @FastInfosetClient Annotation at Design Time
The following code excerpt provides an example of using the com.oracle.webservices.api.FastInfosetClient
annotation to enable and Fast Infoset on a Web service client at design time and configure the content negotiation strategy.
THIS EXAMPLE NEEDS TO BE UPDATED.
package examples.webservices.fastinfoset.client; import com.oracle.webservices.api.FastInfosetClient; import com.oracle.webservices.api.FastInfosetContentNegotiationType; import javax.xml.ws.WebServiceRef; ... public class HelloServicePortClient { @WebServiceRef @FastInfosetClient(fastInfosetContentNegotiation = FastInfosetContentNegotiationType.OPTIMISTIC) private static HelloServiceService helloServiceService; ... }
Example Using FastInfosetClientFeature Feature Class at Design Time
The following code excerpt provides an example of using the com.oracle.webservices.api.FastInfosetClientFeature
feature class to enable and configure Fast Infoset on a web service at design time.
package examples.webservices.hello_world.client; import javax.xml.namespace.QName; import java.net.MalformedURLException; import java.net.URL; import com.oracle.webservices.api.FastInfosetClientFeature; import com.oracle.webservices.api.FastInfosetContentNegotiationType; public class Main { public static void main(String[] args) { HelloWorldService service; FastInfosetContentNegotiationType clientNeg = FastInfosetContentNegotiationType.PESSIMISTIC; FastInfosetClientFeature feature = FastInfosetClientFeature.builder().fastInfosetContentNegotiation(clientNeg).enabled(true).build(); try { service = new HelloWorldService(new URL(args[0] + "?WSDL"), new QName("http://hello_world.webservices.examples/", "HelloWorldService") ); } catch (MalformedURLException murl) { throw new RuntimeException(murl); } HelloWorldPortType port = service.getHelloWorldPortTypePort(feature); String result = null; result = port.sayHelloWorld("Hi there!"); System.out.println( "Got result: " + result ); } }
Disabling Fast Infoset on Web Services and Clients
At design time, to disable Fast Infoset explicitly:
-
On a web service, set the
enabled
flag tofalse
on the annotation, as described in Enabling Fast Infoset on Web Services. -
On a web service client, set the
enabled
flag tofalse
or set the content negotiation strategy toNONE
on the annotation or Feature class, as described in Enabling and Configuring Fast Infoset on Web Services Clients.
The following code excerpt provides an example of using the com.oracle.webservices.api.FastInfosetService
annotation to disable Fast Infoset on a web service at design time.
package examples.webservices.hello_world; import javax.jws.WebService; import com.oracle.webservices.api.FastInfosetService; @WebService(name="HelloWorldPortType", serviceName="HelloWorldService") @FastInfosetService(enabled=false) public class HelloWorldImpl { public String sayHelloWorld(String message) { try { System.out.println("sayHelloWorld:" + message); } catch (Exception ex) { ex.printStackTrace(); } return "Message from FI Enabled Service: '" + message + "'"; } }
At post-deployment time, to disable Fast Infoset:
-
Detach the
oracle/fast_infoset_service_policy
ororacle/fast_infoset_client_policy
policy from the web service or client, respectively.For complete details, see the following sections:
-
Attaching Policies to Web Services and Clients Using Fusion Middleware Control in Securing Web Services and Managing Policies with Oracle Web Services Manager.
-
Configuring Fast Infoset Using WLST in Administering Web Services.
-
-
To disable Fast Infoset globally, at a higher scope on a web service or client, define a policy set that includes
oracle/no_fast_infoset_service_policy
ororacle/no_fast_infoset_client_policy
policy, respectively.For complete details, see the following sections:
-
Attaching Policies Globally Using Policy Sets in Securing Web Services and Managing Policies with Oracle Web Services Manager.
-
Attaching Policies Globally Using Policy Sets Using WLST in Securing Web Services and Managing Policies with Oracle Web Services Manager.
-
Parent topic: Optimizing XML Transmission Using Fast Infoset