Fusion Middleware Documentation
Advanced Search


Developing JAX-WS Web Services for Oracle WebLogic Server
Close Window

Table of Contents

Show All | Collapse

16 Optimizing XML Transmission Using Fast Infoset

This chapter describes how to use Fast Infoset for WebLogic Web services using Java API for XML Web Services (JAX-WS).

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

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.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 + "'"; 
  }
}

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 16-1 summarizes the valid content negotiation strategies defined by com.oracle.webservices.api.FastInfosetContentNegotiationType.

Table 16-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.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:

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