Search This Blog

Thursday, February 23, 2012

BPEL Process to display the IP Address of a hostname

 

Create a BPEL process with the following java embded code ,
<bpelx:exec import="java.net.*"/>
    <bpelx:exec name="Java_Embedding_1" language="java" version="1.3">
      <![CDATA[String ipaddr = (String)getVariableData("stringvar");   
System.out.println(ipaddr); 
try { 
        InetAddress addr1 = InetAddress.getByName(ipaddr); 
          byte[] ipAddr = addr1.getAddress(); 
          // Convert to dot representation 
          String ipAddrStr = ""; 
          for (int i=0; i<ipAddr.length; i++) { 
              if (i > 0) { 
                  ipAddrStr += "."; 
              } 
              ipAddrStr += ipAddr[i]&0xFF; 
          } 
      System.out.println(" Lookup Host Name " +addr1 +" --> " +ipAddrStr); 
      ipaddr = ipAddrStr;

catch(Exception e1) { 
e1.printStackTrace(); 
}
setVariableData("stringvar",ipaddr);]]>
    </bpelx:exec>
Please refer to the Java Doc for the API call's that you can use in BPEL java
http://docs.oracle.com/cd/B31017_01/integrate.1013/b28986/com/collaxa/cube/engine/ext/BaseBPELXExecLet.html
http://technology.amis.nl/blog/2387/embedding-java-in-bpel-process
http://niallcblogs.blogspot.in/2008/01/bpel-embedded-java.html

Thursday, February 02, 2012

EJB Out Bound Example in SOA

 

1. Create a Simple EJB HelloWorld Application and deploy this to the WebLogic Server

Refer to the file below for the example ,

Hello EJB Example

2. Create a new composite and create a mediator component ,

3. In the External Reference drop the ejb Service and specify the EJB JNDI Binding Name  say

OS9SOAApplication-HelloEJB-HelloEJB#test.os9.model.HelloEJB

EJB-Jar file :

and Java Interface : test.os9.model.HelloEJB

4. Wire the EJB Outbound Service to the mediator and perform the XML transformations and run the example ,

Refer to the file in the link given below ,

Calling EJB from Mediator/BPEL

Simple inbound ejb example ,

 

1. Create a java file with the following contents

package test.os9;
//import javax.ejb.Remote;
//@Remote
public interface Hello {
public String sayHello(String input);
}

Compile this file , create a class file and create a jar file and copy the jar file to SCA-INF\lib directory

2. Create an EJB Binding in the Services lane, based on this Java interface. Specify the JNDI Name for this EJB. For example: ejb/EjbBind and select the above interface file and the jar

3. Create a Mediator with no interface definition and Wire this mediator to this EJB Service

4. Create a BPEL process and wire this to the Medaitor

5. Create the mappings for the mediator

6. Create an EJB Client with the following code ,

package test.os9;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class EjbClient {
  public EjbClient() {
    super();
  }
  public static void main(String[] args) {
    EjbClient ejbClient = new EjbClient();
    try {
     final Context context = getInitialContext();
     Hello hello = (Hello)context.lookup("ejb/EjbBind");
     System.out.println(hello.sayHello("hello ravi"));
     } catch (Exception ex) {
     ex.printStackTrace();
     }
  }
  private static Context getInitialContext() throws NamingException {
  Hashtable env = new Hashtable();
  // WebLogic Server 10.x connection details
  env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
  env.put(Context.PROVIDER_URL, "t3://xxx.xxx.oracle.com:7001");
    env.put(Context.SECURITY_PRINCIPAL,"weblogic");
    env.put(Context.SECURITY_CREDENTIALS,"xxxxx");
  return new InitialContext( env );
  }
}

Add the following libraries to compile the class files 

   "EJB 3.0" and "WebLogic 10.3 Remote-Client"

Here is the example ,

Download Example