JAX-RPC 2.0 Early Access
Provider


Last Modified: 04/04/05

Web service endpoints may choose to work at the XML messasge level by implementing the Provider interface. This is achieved by implementing either Provider<Source> or Provider<SOAPMessage>. The endpoint accesses the message or message payload using this low-level, generic API. The @ServiceMode annontation is used to convey whether the endpoint wants to access the message (Service.Mode.MESSAGE) or payload (Service.Mode.PAYLOAD). If there is no @ServiceMode annotation on the endpoint, payload is the default value. The endpoint communicates with handlers using the properties set in the JAXRPCContext parameter. All the provider endpoints start from a WSDL file and <provider> WSDL customization can be used to mark a port as a provider.

Provider<Source> and PAYLOAD

An endpoint can access only the payload of a request using Service.Mode.PAYLOAD in the@ServiceMode annotation. This is the default behaviour, if the annotation is missing.

For example:

  public class ProviderImpl implements Provider<Source> {
      public Source invoke(Source source, JAXRPCContext context) throws RemoteException {
              // do request processing
              Source response = ...;
              return response;
      }
  }


Provider<SOAPMessage> and MESSAGE

An endpoint can access an entire SOAP request as a SOAPMessage. Service.Mode.MESSAGE in the @ServiceMode annotation is used to convey the intent.

For example:

  @ServiceMode(value=Service.Mode.MESSAGE)
  public class ProviderImpl implements Provider<SOAPMessage> {
      public SOAPMessage invoke(SOAPMessage msg, JAXRPCContext ctxt) throws RemoteException {
              // do request processing
              SOAPMessage response = ...;
              return response;
      }
  }


Provider<Source> and MESSAGE

An endpoint can access a request as a Source. If the request is a SOAPMessage, only the SOAPPart (no attachments) of the message is passed as Source to the invoke method. If the returned response is null, it is considered a one way MEP.

For example:

  @ServiceMode(value=Service.Mode.MESSAGE)
  public class ProviderImpl implements Provider<Source> {
      public Source invoke(Source source, JAXRPCContext context) throws RemoteException {
              // Use JAXRPCContext to access properties set by handler
              String foo = (String)context.getProperty("foo");

              // do request processing using source
              // return null to indicate oneway
              return null;
      }
  }


WSDL Customization

The provider endpoint starts with a WSDL file. A port can be customized to a provider endpoint using the <provider> customization.

For example:

  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <bindings
  ...
          wsdlLocation="AddNumbers.wsdl"
          xmlns="http://java.sun.com/xml/ns/jaxrpc">
          <bindings node="wsdl:definitions" >
          <package name="provider.server"/>
          <provider>true</provider>
          </bindings>
  </bindings>


The jaxrpc-ri.xml file

wsdeploy uses jaxrpc-ri.xml to read configuration information and generate implementation-specific artifacts like _Tie.class for a provider endpoint. The interface attribute should point to javax.xml.rpc.Provider in jaxrpc-ri.xml.

>

For example:

  <webServices ... >
          <endpoint
          name="provider"
          displayName="Provider From WSDL"
          interface="javax.xml.rpc.Provider"
          implementation="provider.server.AddNumbersImpl"
          wsdl="/WEB-INF/AddNumbers.wsdl"
          model="/WEB-INF/jaxrpc-provider-model.xml.gz"/>
          ...
  </webServices>



Copyright © 2005 Sun Microsystems, Inc. All rights reserved.