7 Optimizing XML Transmission Using Fast Infoset

This chapter describes how to use Fast Infoset for Oracle Infrastructure web services.

This chapter includes the following sections:

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 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.

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, using one of the following methods:

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.fastinfoset;
import com.oracle.webservcies.api.FastInfosetService;
import oracle.webservices.annotations.PortableWebService;
import javax.jws.WebMethod;

@PortableWebService 
@FastInfosetService(enabled = true) 
public class HelloImplFastInfosetEnabled { 
   @WebMethod 
   public String hello(String name) { 
      return "Hello, " + name + "! (from FI Enabled Service)"; 
   } 
} 

For more information about the @PortableWebService annotation, see Java API Reference for Oracle Infrastructure Web Services.

Enabling and Configuring Fast Infoset on Web Services Clients

You can explicitly enable and configure Fast Infoset on a web service client, using one of the following methods:

Configuring the Content Negotiation Strategy

When enabling Fast Infoset on the client, you can configure the content negotiation policy. Table 7-1 summarizes the valid content negotiation strategies defined by com.oracle.webservices.api.FastInfosetContentNegotiationType.

Table 7-1 Content Negotiation Strategy

Value Description

OPTIMISTIC

Assumes that Fast Infoset is enabled on the service. All requests will be sent using Fast Infoset.

PESSIMISTIC

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.

NONE

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 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.fastinfoset;
import com.oracle.webservices.api.FastInfosetClientFeature;
import com.oracle.webservices.api.FastInfosetContentNegotiationType;
import javax.xml.ws.WebServiceRef;
...
public class HelloServicePortClient {
    @WebServiceRef
    private static HelloServiceService helloServiceService;

    public static void main(String [] args)
    {
        FastInfosetContentNegotiationType clientNeg = 
            FastInfosetContentNegotiationType.PESSIMISTIC;
        FastInfosetClientFeature feature = FastInfosetClientFeature.builder().fastInfosetContentNegotiation(clientNeg).enabled(true).build(); 
        helloServiceService = new HelloServiceService();
        HelloService helloService = 
            helloServiceService.getHelloServicePort(feature);
...
}

Disabling Fast Infoset on Web Services and Clients

At design time, to disable Fast Infoset explicitly:

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.fastinfoset;
import com.oracle.webservices.api.FastInfosetService;
...
@PortableWebService 
@FastInfosetService(enabled = false) 
public class HelloImplFastInfosetDisabled{ 
   @WebMethod 
   public String hello(String name) { 
      return "Hello, " + name + "! (from FI Disabled Service)"; 
   } 
} 

At post-deployment time, to disable Fast Infoset:

  • Detach the oracle/fast_infoset_service_policy or oracle/fast_infoset_client_policy policy from the web service or client, respectively.

    For complete details, see the following sections:

  • 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 or oracle/no_fast_infoset_client_policy policy, respectively.

    For complete details, see the following sections: