Skip Headers
Oracle® Fusion Middleware Developer's Guide for Oracle SOA Suite
11g Release 1 (11.1.1.6.2)

Part Number E10224-14
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

39 Using the Direct Binding Invocation API

This chapter describes the Direct Binding Invocation API and how to invoke a SOA composite application. It describes how to create an inbound direct binding service, how to create an outbound direct binding reference, and how to set an identity for J2SE clients invoking direct binding. Samples of using the Direct Binding Invocation API are also provided.

This chapter includes the following sections:

39.1 Introduction to Direct Binding

A common way to invoke a composite is to use SOAP over HTTP. This is enabled by creating a SOAP service for your composite using web service binding. However, you can also use direct binding, which provides a tighter integration alternative. Direct binding enables Java clients to directly invoke composite services, bypassing the intermediate conversion to XML required with web service binding.

Direct binding provides two types of invocation styles:

Direct binding must be associated with the interface.wsdl, providing the interface clause and, optionally, the callbackInterface clause. The associated WSDL must be imported into the composite.

The service binding component also publishes a modified version of the WSDL that advertises the direct binding.

39.1.1 Direct Service Binding Component

A sample configuration using the direct service binding component is shown in Example 39-1.

Example 39-1 Direct Service Binding Component

<service name="direct2">
      <interface.wsdl
interface="http://xmlns.oracle.com/asyncNonConvDocLit#wsdl.interface(asyncNonConvD
ocLit)"
callbackInterface="http://xmlns.oracle.com/asyncNonConvDocLit#wsdl.interface(async
NonConvDocLitCallback)" xmlns:ns="http://xmlns.oracle.com/sca/1.0"/>
      <binding.direct/>
</service>

39.1.2 Direct Reference Binding Component

The direct reference binding component requires the following information to connect to a user-provided SOA invoker:

  • Properties:

    A set of properties that defines the DirectConnection for the end service.

  • ConnectionFactory class name:

    The ConnectionFactory class must implement the oracle.soa.api.invocation.DirectConnectFactory interface.

  • Address used by the external service:

    This address value is not processed by the binding component, but is passed on to the service bean during invocation.

  • AddressingVersion (optional):

    The default addressing version used is 2005/08.

  • useSSLForCallback:

    Use SSL for the callback JNDI connection. If this flag is set to true, then the WSA replyTo header instructs the service to call back at an SSL JNDI port.

A sample configuration is shown in Example 39-2.

Example 39-2 Sample Configuration

<reference name="HelloReference" ui:wsdlLocation="HelloService.wsdl">
  <interface.wsdl
 interface="http://hello.demo.oracle/#wsdl.interface(HelloInterface)"/>
  <binding.direct connection-factory="oracle.soa.api.JNDIDirectConnectionFactory"
   addressingVersion="http://www.w3.org/2005/08/addressing"
   address="soadirect://syncOut"
   useSSLForCallback="false">
  <property
 name="oracle.soa.api.invocation.direct.bean">MyDirectTestServiceBean#directEjb.Tes
tInvoker</property>
  <property
 name="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</property
>
 <property name="java.naming.provider.url">t3://@host:@port</property>
 </binding.direct>
</reference>

The direct binding components support both synchronous and asynchronous invocation patterns. Figure 39-1 describes a sample synchronous invocation pattern and Figure 39-2 describes a sample asynchronous invocation pattern.

Figure 39-1 Sample Synchronous Invocation Patterns

Sample Synchronous
Description of "Figure 39-1 Sample Synchronous Invocation Patterns"

Figure 39-2 Sample Asynchronous Invocation Pattern

Sample Asynchronous
Description of "Figure 39-2 Sample Asynchronous Invocation Pattern"

39.2 Introduction to the Direct Binding Invocation API

The different packages used in the Direct Binding Invocation API are as follows:

39.2.1 Synchronous Direct Binding Invocation

Direct binding also supports the synchronous direct invocation with the usage of the method shown in Example 39-5.

Example 39-5 Synchronous Direct Invocation

<T> Message<T> request(String operationName, Message<T> message)
 throws InvocationException, FaultException

39.2.2 Asynchronous Direct Binding Invocation

Asynchronous invocation relies on the WS-Addressing headers set on the message instance. All headers must adhere to the WS-Addressing specification.

The Direct Binding Invocation API allows the clients to specify the WS-Addressing ReplyTo SOAP header to communicate a destination by which they can receive responses.

An example of the WS-Addressing header used for asynchronous invocation is shown in Example 39-6.

Example 39-6 WS-Addressing Header

<wsa:MessageID>D6202742-D9D9-4023-8167-EF0AB81042EC</wsa:MessageID>
   <wsa:ReplyTo xmlns:wsa="http://www.w3.org/2005/08/addressing">
     <wsa:Address>sb://testserver:9001/callback</wsa:Address>
      <wsa:ReferenceParameters>
        <soa:callback xmlns:soa="http://xmlns.oracle.com/soa/direct"
           connection-factory="mytest.MyDirectionConnectionFactory">
        <soa:property name="oracle.soa.api.invocation.direct.bean"
           value="myTest.MyDirectConnectionBean"/>
        <soa:property name="java.naming.provider.url" value="t3://test:8001"/>
        <soa:property name="java.naming.factory.initial"
           value="weblogic.jndi.WLInitialContextFactory"/>
        </soa:callback>
      </wsa:ReferenceParameters>
   </wsa:ReplyTo>

Note:

You must qualify the callback and its property elements properly with the SOA direct namespace.

The direct binding component is responsible for parsing the addressing headers set on the message instance. In this example, there are two headers: wsa:MessageID and wsa:ReplyTo. The service binding component makes the following properties available for the internal SOA components:

  • tracking.conversationId = D6202742-D9D9-4023-8167-EF0AB81042E

  • replyToAddress = sb://testserver:9001/callback

  • replyToReferenceParameter : element of WSA:ReferenceParameters

39.2.3 SOA Direct Address Syntax

The service paths used with the Direct Binding Invocation API follow the SOA direct address pattern:

  • soadirect:/CompositeDN/serviceName, where CompositeDN stands for composite distinguished name

In the SOA direct address, the CompositeDN has the following form:

domainName/compositeName[!compositeVersion[*label]]

39.2.4 SOA Transaction Propagation

Direct binding supports the SOA transaction propagation feature. You can invoke this feature from the client in the following ways:

  • Begin the Java transaction from the client and, after performing all the database operations, perform a commit. You should commit the database operations after a successful commit from the client side.

  • Begin the Java transaction from the client side. If a fault is thrown back during any operation in the SOA composite, then roll back the transaction from the client side. This rolls back all the database operations.

39.3 Invoking a SOA Composite Application with the Invocation API

The Direct Binding component in Oracle JDeveloper, as shown in Figure 39-3, provides support for exchanging SOA messages with SOA over RMI.

Figure 39-3 Direct Binding Option

Direct Binding Option
Description of "Figure 39-3 Direct Binding Option"

Oracle JDeveloper supports creating a direct service binding and a direct reference binding that invokes either an Oracle Service Bus or another SOA composite.

Note:

For a client to invoke composite services over direct binding, its class path must include both soa-infra-mgmt.jar and oracle-soa-client-api.jar.

For more information about the Direct Binding Invocation API, see Section 39.2, "Introduction to the Direct Binding Invocation API."

39.3.1 How to Create an Inbound Direct Binding Service

You can invoke a SOA composite application using the Direct Binding option in Oracle JDeveloper.

To create an inbound direct binding service:

  1. Open Oracle JDeveloper.

  2. From the Component Palette, select SOA.

  3. From the Service Adapters list, drag the Direct Binding component into the Exposed Services swimlane. The Create Direct Binding dialog appears.

  4. Enter the details shown in Table 39-1.

    Table 39-1 Direct Binding Service Dialog Fields and Values

    Field Value

    Name

    Enter a name.

    Type

    Select Service from the list.

    Reference Target

    This field is disabled when defining this service in the Exposed Services swimlane.

    WSDL URL

    The URL location of the WSDL file. If you have an existing WSDL, then click the Find Existing WSDLs option. Otherwise, click Generate WSDL from schema(s).

    Port Type

    The port type of the WSDL file. You must select a port from the list.

    Callback Port Type

    The callback port type for asynchronous processes.

    Use SSL For Callback

    Select to use SSL for the callback.

    Address

    This field is automatically populated when the WSDL is concrete and it has at least one binding that is direct.

    Provider URL

    This field is automatically populated when the WSDL is concrete and it has at least one binding that is direct.

    Use local JNDI Provider

    Select to use the local JNDI provider.

    copy wsdl and its dependent artifacts into the project

    Deselect this checkbox. If you select this checkbox, the local copies of the WSDL file may result in synchronization issues if a remote WSDL is updated.


    When complete, the Create Direct Binding dialog appears as shown in Figure 39-4.

    Figure 39-4 Create Direct Binding Dialog

    Create Direct Binding Dialog
    Description of "Figure 39-4 Create Direct Binding Dialog"

  5. Click OK.

    The direct binding service displays in the SOA Composite Editor shown in Figure 39-5. The single arrow in a circle indicates that this is a synchronous, one-way, direct binding component.

    Figure 39-5 Direct Binding Service

    Direct Binding Service
    Description of "Figure 39-5 Direct Binding Service"

39.3.2 How to Create an Outbound Direct Binding Reference

You can create an outbound direct binding reference, using the Direct Binding option in Oracle JDeveloper, to either invoke a composite application or an Oracle Service Bus.

To create an outbound direct binding reference:

  1. Open Oracle JDeveloper.

  2. From the Component Palette, select SOA.

  3. From the Service Adapters list, drag the Direct Binding component into the External References swimlane. The Create Direct Binding dialog appears.

  4. Enter the details shown in Table 39-2.

    Table 39-2 Direct Binding Service Dialog Fields and Values

    Field Value

    Name

    Enter a name.

    Type

    Select Reference from the list.

    Reference Target

    Select the reference target on which you want the direct binding service to operate:

    • Oracle SOA Composite: Creates a direct binding with a SOA composite application as a reference target.

    • Oracle Service Bus: Creates a direct binding with an Oracle Service Bus as a reference target.

    WSDL URL

    The URL location of the WSDL file. If you have an existing WSDL, then click the Find Existing WSDLs option.

    Port Type

    The port type of the WSDL file. You must select a port from the list.

    Callback Port Type

    The callback port type for asynchronous processes.

    Use SSL For Callback

    Select to use SSL for the callback.

    Address

    This field is automatically populated when you select a concrete WSDL URL and port type. However, you must manually populate this field if a nonconcrete WSDL is provided.

    Provider URL

    This field is automatically populated when you select a concrete WSDL URL and port type. However, you must manually populate this field if a nonconcrete WSDL is provided.

    Use local JNDI Provider

    Select to use the local JNDI provider.

    copy wsdl and its dependent artifacts into the project

    Deselect this checkbox. If you select this checkbox, the local copies of the WSDL file may result in synchronization issues if a remote WSDL is updated.


    When complete, the Create Direct Binding dialog appears as shown in Figure 39-6. For more information about using the Oracle SOA Suite services with Oracle Service Bus, see the Oracle SOA Suite Transport (SOA-DIRECT) chapter in Oracle Fusion Middleware Developer's Guide for Oracle Service Bus.

    Figure 39-6 Create Direct Binding Dialog

    Create Direct Binding Dialog
    Description of "Figure 39-6 Create Direct Binding Dialog"

  5. Click OK.

    The direct binding reference displays in the designer shown in Figure 39-7. The single arrow in a circle indicates that this is a synchronous, one-way direct binding reference component.

    Figure 39-7 Direct Binding Reference

    Direct Binding Reference
    Description of "Figure 39-7 Direct Binding Reference"

39.3.3 How to Set an Identity for J2SE Clients Invoking Direct Binding

J2SE clients can set an identity while invoking direct binding, as shown in Example 39-7.

Example 39-7 Identity Setup for J2SE Clients Invoking Direct Binding

public static void main(String[] args) throws Exception {
    String operation = "process";

    // This is the request message XML
    String ns = "http://xmlns.oracle.com/DirectBinding_jws/EchoBPEL/BPELProcess1";
    String payloadXML = "<ns1:process xmlns:ns1=\"" + ns + "\">\n" +
                        "  <ns1:input>wew</ns1:input>\n" +
                        "</ns1:process>"; 

    String serviceAddress = "soadirect:/default/EchoBPEL!1.0/DService1";

    // Specify the direct binding connection properties
    Map<String, Object> props = new HashMap<String, Object>();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL, "t3://" + hostname + ':' + portname);
    props.put(Context.SECURITY_PRINCIPAL,username);
    props.put(Context.SECURITY_CREDENTIALS, password);

    // Create the direct binding connection, using those context properties
    DirectConnectionFactory factory = JNDIDirectConnectionFactory.newInstance();

    try {
       DirectConnection dc = factory.createConnection(serviceAddress, props);

        // Parse the XML request message
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        Document doc =
          dbf.newDocumentBuilder().parse(new InputSource(new StringReader(payloadXML)));

        // Prepare the payload for inclusion in the Message object
        Map<String, Element> payload = new HashMap<String, Element>();
        payload.put("payload", doc.getDocumentElement());

        Message<Element> request = XMLMessageFactory.getInstance().createMessage(payload);

        Message<Element> response = dc.request(operation, request);
    } finally {
        dc.close();
    }
}

39.3.4 What You May Need to Know About Invoking SOA Composites on Hosts with the Same Server and Domain Names

If one SOA composite application invokes another SOA composite application on another host through direct binding, and both composites are on hosts with the same server name and domain name, the invocation fails.

This is because the Oracle WebLogic Server transaction subsystem requires the domain names and server names to be different for transaction management to work properly. The transaction subsystem uses these names to track the location of a server related to a transaction. If the two servers in the invocation have the same name, the transaction subsystem can mistakenly confuse the two servers.

Ensure that you use hosts with separate server names and domain names.

39.4 Samples Using the Direct Binding Invocation API

Example 39-8 through Example 39-10 provide some examples of how the API is used. This section describes how the connection parameter can invoke SOA composite applications over direct binding and how message objects can be modified to invoke a direct binding invocation.

Example 39-8 Usage of a Connection Parameter

// The JNDIDirectConnectionFactory can be used to establish SOA instance
// connections for exchanging messages over the direct binding.
DirectConnectionFactory dcFactory = JNDIDirectConnectionFactory.newInstance();

// Connections are created based on the configuration, which is a map of standard
// naming properties, which will be used for the underlying connection lookup.
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(Context.INITIAL_CONTEXT_FACTORY, jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://HOST:PORT");
properties.put(Context.SECURITY_PRINCIPAL, USERNAME); 
propertie.put(Context.SECURITY_CREDENTIALS, PASSWORD);
DirectConnection conn =
    dcFactory.createConnection("soadirect:/default/MyComposite!1.0/MyService",
                               properties);

Example 39-9 Usage of Messages

// Messages are created using the MessageFactory
// Message objects are subsequently modified to be used for an invocation.
Message<Element> request = XMLMessageFactory.getInstance().createMessage();

// Define a Map of WSDL part names to matching XML Element objects
Map<String, Element> partData;

Payload<Element> payload = PayloadFactory.createXMLPayload(partData);
request.setPayload(payload);

// One-way invocation
conn.post("onewayoperation", request);

// Request-reply invocation
Message<Element> response = conn.request("requestreplyoperation", request);

Example 39-10 Usage of LocatorFactory and DirectConnection Creation

Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL, "t3://" + HOST + ':' + PORT);
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,
              "weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL,USERNAME); 
jndiProps.put(Context.SECURITY_CREDENTIALS, PASSWORD);
Locator locator = LocatorFactory.createLocator(jndiProps);
CompositeDN compositedn = new CompositeDN(domainName, compositename, version);
String serviceName = "HelloEntry";
DirectConnection conn = locator.createDirectConnection(compositedn, serviceName);