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

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

Go to previous page
Previous
Go to next page
Next
View PDF

37 Using the Direct Binding Invocation API

This chapter describes the Direct Binding Invocation API and how it can invoke SOA composite applications.

This chapter includes the following sections:

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

Direct Service Binding Component

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

Example 37-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>

Direct Reference Binding Component

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

A sample configuration is shown in Example 37-2.

Example 37-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 37-1 describes a sample synchronous invocation pattern and Figure 37-2 describes a sample asynchronous invocation pattern.

Figure 37-1 Sample Synchronous Invocation Patterns

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

Figure 37-2 Sample Asynchronous Invocation Pattern

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

37.2 Introduction to the Direct Binding Invocation API

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

For more information about the Facades API, see Oracle Fusion Middleware Infrastructure Management Java API Reference for Oracle SOA Suite.

37.2.1 Synchronous Direct Binding Invocation

Direct binding also supports the Synchronous Direct Invocation with the usage of the method:

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

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

Example 37-7 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 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

37.2.3 SOA Direct Address Syntax

The service paths used with the SOA 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]]

37.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, do a commit. You should commit the database operations after a successful commit from the client side.

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

37.3 Invoking a SOA Composite Application with the Invocation API

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

Figure 37-3 Direct Binding Option

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

Oracle JDeveloper supports creating a direct service binding and a direct reference binding invoking 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 37.2, "Introduction to the Direct Binding Invocation API."

37.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 Components list, drag the Direct Binding component into the Exposed Services swimlane. The Create Direct Binding dialog appears.

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

    Table 37-1 Direct Binding Service Dialog Fields and Values

    Field Value

    Name

    Enter a name.

    Type

    Select Service from the list.

    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.

    Reference Binding Details

     

    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.

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

    Figure 37-4 Create Direct Binding Dialog

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

  5. Click OK.

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

    Figure 37-5 Direct Binding Service

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

37.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 invoking 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 Components list, drag the Direct Binding component into the External References swimlane. The Create Direct Binding dialog appears.

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

    Table 37-2 Direct Binding Service Dialog Fields and Values

    Field Value

    Name

    Enter a name.

    Type

    Select Reference from the list.

    Reference Target

    To use SOA as an external reference target, select Oracle SOA Composite and to use Oracle Service Bus as an external reference target, select Oracle Service Bus.

    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. In this example, the value execute_ptt appears in this field.

    Reference Binding Details

     

    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.

    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 37-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 37-6 Create Direct Binding Dialog

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

  5. Click OK.

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

    Figure 37-7 Direct Binding Reference

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

37.4 Samples Using the Direct Binding Invocation API

Example 37-8 through Example 37-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 37-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,
 "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://HOST:PORT");
DirectConnection conn =
    dcFactory.createConnection("soadirect:/default/MyComposite!1.0/MyService",
 properties);

Example 37-9 Usage of Messages

//Messages are created using the MessageFactory 
Message<Element> request = XMLMessageFactory.getInstance().createMessage();

//Message objects are then modified to be used for an invocation 
Map<String, Element> partData; // Define a Map of WSDL part names to matching XML
 Element objects
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 37-10 Usage of LocatorFactory

//A Sample Java Code
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL, "t3://" + hostname + ':' + portname +
 "/soa-infra");
jndiProps.put(Context.INITIAL_CONTEXT
-FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL,"weblogic"); 
jndiProps.put(Context.SECURITY_CREDENTIALS,"welcome1");
jndiProps.put("dedicated.connection","true");
Locator locator = LocatorFactory.createLocator(jndiProps);
CompositeDN compositedn = new CompositeDN(domainName, compositename, version);
String serviceName = "HelloEntry";
return locator.createDirectConnection(compositedn, serviceName);