Implementing extensions to JAX-RPC web services clients

WebSphere® Application Server provides extensions to web services clients using the Java™ API for XML-based RPC (JAX-RPC) programming model.

About this task

You can customize web services by using the following extensions to the JAX-RPC client programming model.

Procedure

  • Set the REQUEST_SOAP_HEADERS and RESPONSE_SOAP_HEADERS properties in a JAX-RPC client Stub to enable a web services client to send or retrieve implicit SOAP headers.
    An implicit SOAP header is a SOAP header that is not explicitly defined in the WSDL file. An implicit SOAP header file fits one of the following descriptions:
    • A message part that is declared as a SOAP header in the binding in the WSDL file, but the message definition is not referenced by a portType within a WSDL file.
    • An element that is not contained in the WSDL file.

    Handlers and service endpoints can manipulate implicit or explicit SOAP headers using the SOAP with Attachments API for Java (SAAJ) data model.

    To learn how to modify your client code to send or retrieve transport headers, see the information on sending implicit SOAP headers with JAX-RPC or receiving implicit SOAP headers with JAX-RPC.

  • Set the REQUEST_TRANSPORT_PROPERTIES and RESPONSE_TRANSPORT_PROPERTIES properties to enable a web services client to send or retrieve transport headers.

    Set the properties on the Stub or Call object.

    By modifying your client code to send or retrieve transport headers, you can send or receive specific information within the transport headers of outgoing requests or incoming responses from the server. For requests or responses that use the HTTP transport, the information is sent or retrieved in an HTTP header. Similarly, for a request or response that uses the Java Message Service (JMS) transport, the information is sent or retrieved in a JMS message property.

    To learn how to modify your client code to send or retrieve transport headers, see the information on sending transport headers with JAX-RPC or retrieving transport headers with JAX-RPC.

    To learn how to enable a Web services client to send or retrieve transport headers, see the transport header properties best practices information.

  • Implement support for javax.xml.rpc.ServiceFactory.loadService() methods.
    The loadService methods create an instance of the generated service implementation class in an implementation-specific manner. The loadService methods are new for JAX-RPC 1.1 and include three signatures:
    • public.javax.xml.rpc.Service loadService (Class serviceInterface)

      As documented in the JAX-RPC specification, this method returns the generated service implementation for the service interface. See the web services specifications and API documentation to review the JAX-RPC specification.

    • public.javax.xml.rpc.Service loadService (URL wsdlDocumentLocation, Class serviceInterface, Properties properties)
      This method behaves like the loadService (Class serviceInterface) because the following parameters are ignored:
      • wsdlDocumentLocation
      • properties
    • public.javax.xml.rpc.Service loadService (URL wsdlDocumentLocation, QName serviceName, Properties properties)

      This method returns the generated service implementation for the specified service by using optional namespace-to-package mapping information.

      • wsdlDocumentLocation - ignored
      • serviceName - QName (namespace, localpart) of the service
      • properties - If this parameter is non-null, it contains namespace-to-package mapping entries. Each Property entry key is a String corresponding to the namespace. Each Property entry value is a String corresponding to the Java package name.

        If the properties argument contains an entry with a key (namespace) that matches the namespace portion of the QName serviceName argument, the entry value (javaPackage) is used as the package name when trying to locate the service implementation.

    For more information on these methods, see the JAX-RPC specification.
  • Implement the CustomBinder interface to provide concrete custom data binders for a specific XML schema type (JAX-RPC applications only).
    Custom data binders are used to map XML schema types with Java objects. Custom data binders provide bindings for XML schema types that are not supported by the current Java API for XML-based Remote Call Procedure (JAX-RPC) specification. WebSphere Application Server provides an extension to the Web Services for Java Platform, Enterprise Edition (Java EE) programming model called the CustomBinder interface that implements these custom bindings for a specific XML schema type. The CustomBinder interface has three properties, in addition to deserialize and serialize methods:
    • QName for the XML schema type
    • QName scope
    • Java type

    The custom data binder defines serialize and deserialize methods to convert between a Java object and a SOAPElement interface. A custom data binder is added to the runtime system and interacts with the web services runtime using a SOAPElement. They are added to the runtime by using custom binding providers. Read about the custom data binders and the custom binding provider to learn more. See the CustomBinder interface documentation to learn more about how you can implement this interface to provide concrete custom data binders for a specific XML schema type.