Skip to main content

Manipulating Oracle Gateway Entity Store with gateway SDK

Oracle Enterprise Gateway (OEG) is built in gateway product from company Vordel to simplify and secure SOA deployments. OEG replaces Oracle web service manager functionality for SOA development. In real life, most of all time we have a lot of services to registered in OWSM or in OEG. Even more, it was not possible to migrate registered services from one node to another on OWSM. When we got plan to migrate from OWSM to OEG, our main aim was to register web services automatically through API. I was very happy, when found OEG provides some SDK to working with registry. Here is the first attempt to working with OEG SDK. We will use maven to build our project. OEG entity store consolidate all the entities and objects uses in the repository, for example all the registered services and policies. Through Entity store you can add, update and delete any entity. In OTN you can find one tutorial to develop a custom policy through OEG SDK. OEG also provide entity explorer to working with entity store, %OEG_HOME%\Win32\bin\esexplorer.bat First we will install all the necessary libraries on maven local repository.
set OEG_HOME=c:/OEG/gateway/system

call mvn install:install-file -DgroupId=com.vordel -DartifactId=client -Dversion=1.0 -Dfile=%OEG_HOME%/lib/client.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=com.vordel -DartifactId=common -Dversion=1.0 -Dfile=%OEG_HOME%/lib/common.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=com.vordel -DartifactId=entityStore -Dversion=1.0 -Dfile=%OEG_HOME%/lib/entityStore.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.axis -DartifactId=axis -Dversion=1.0 -Dfile=%OEG_HOME%/lib/modules/axis.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.commons -DartifactId=commons-discovery -Dversion=0.2 -Dfile=%OEG_HOME%/lib/modules/commons-discovery-0.2.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=org.apache.commons -DartifactId=commons-logging -Dversion=1.0.4 -Dfile=%OEG_HOME%/lib/modules/commons-logging-1.0.4.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=javax.xml.rpc -DartifactId=jaxrpc -Dversion=1.0 -Dfile=%OEG_HOME%/lib/modules/jaxrpc.jar -Dpackaging=jar -DgeneratePom=true
call mvn install:install-file -DgroupId=javax.wsdl -DartifactId=javax.wsdl_api -Dversion=1.6.2 -Dfile=%OEG_HOME%/lib/plugins/javax.wsdl_api_1.6.2.jar -Dpackaging=jar -DgeneratePom=true
rem add also Win32\lib\vjni.lib in your classpath
After running the above script, we will got all the libraries on our maven local repository. For working correctly, we also have to add vjni.dll file on our classpath. For windows we can do it through PATH variable, for linux platform we can use LD_LIBRARY_PATH. Next we have to create a maven project and add all the dependencies on it as follows:
<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.vordel</groupId>
      <artifactId>client</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>com.vordel</groupId>
      <artifactId>common</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>com.vordel</groupId>
      <artifactId>entityStore</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.axis</groupId>
      <artifactId>axis</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-discovery</artifactId>
      <version>0.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.0.4</version>
    </dependency>
    <dependency>
      <groupId>javax.xml.rpc</groupId>
      <artifactId>jaxrpc</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>javax.wsdl</groupId>
      <artifactId>javax.wsdl_api</artifactId>
      <version>1.6.2</version>
    </dependency>
  </dependencies>
Now we are ready to write some code and manipulate with OEG entity store. Here is our some pseudo code to manipulate entity.
public class EntityStoreFactory {
    private EntityStoreFactory(){};
 
    public static EntityStore getEntityStore(final String URL, final String userName, final String password) throws EntityStoreException{
        com.vordel.es.EntityStoreFactory efs = com.vordel.es.EntityStoreFactory.getInstance();
        efs.registerForURL(URL, com.vordel.es.provider.soap.client.SOAPStore.class, new ArrayList<string>(2){{add(userName); add(password);}});
        return efs.getEntityStoreForURL(URL);
    }
}
For testing purpose we are using SOAP provider to connect, but it's possible to use another type of provide such as LDAP, DB e.t.c. You can find the configuration file for the entity store factory in the following place %OEG_HOME%\gateway\system\conf\esproviders.xml .Even you can initialize provider as follows^
efs.initializeProviders(new FileInputStream("%OEG_HOME%\\enterprisegateway\\system\\conf\\esproviders.xml"));
through getEntityStore we can get the entityStore and ready to manipulate entity.
public class AddEntity {
    private static Properties props = new Properties();
    static{
        props.put("javax.xml.rpc.security.auth.username","admin");
        props.put("javax.xml.rpc.security.auth.password","changeme");
    }

    public static void main(String[] args) {
        final String url = "http://localhost:8090/configuration/policies";

        System.out.println("Test Vordel ES api");
        EntityStore es = null;
        try {
            es = EntityStoreFactory.getEntityStore(url,"admin","changeme");
            es.connect(url, props);
            // test connection
            ESPK rootESPK =  es.getRootPK();
            System.out.println("Root:"+ rootESPK.toString());
            /** Get the example webservice entity for simplicity, assume we have one web service registered **/
            // get the web services
            ESPK espkBRs = new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:1668"); // added through service manager http://www.webservicex.net/stockquote.asmx?WSDL
            com.vordel.es.Entity entBrs = es.getEntity(espkBRs);
            // add test entity
            ESPK parentPK = new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:147");
            com.vordel.es.Entity newEntity = new com.vordel.es.Entity(entBrs.getType()); // webservice type
            // add more fields
            // add parent key
            newEntity.setStringField("name", "testby-api");
            Value primaryWsdlValue = new Value();
            newEntity.setReferenceField("primaryWSDL", new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:1670"));

            ESPK newAddEspk = es.addEntity(parentPK, newEntity);
            System.out.println("NewEspk:"+ newAddEspk);
            // add more element on it - ex wsdl
            EntityType wsdlEType = new EntityTypeImpl(es, "");
            com.vordel.es.Entity wsdlEntity = new com.vordel.es.Entity(wsdlEType);
            wsdlEntity.setStringField("uri", "http://localhost:9000/StockQuote?WSDL");
            wsdlEntity.setStringField("wsdl", "http://localhost:9000/StockQuote?WSDL");
            es.addEntity(newAddEspk, wsdlEntity);
            // add Generated circuits
            // get Circuite container for example
            ESPK parentCircuiteCPK = new ESStringPK("DEFAULT_PRIMARY_OracleGateway_6.1.2:1655");
            com.vordel.es.Entity newCCType = new com.vordel.es.Entity(es.getEntity(parentCircuiteCPK).getType()); // Contained type
            ESPK newCCForTest = es.addEntity(parentCircuiteCPK, newCCType);
            // add filter circuit
        } catch (EntityStoreException e) {
            e.printStackTrace();
        } finally {
            if(es!=null){
                try {
                    es.disconnect();
                } catch (EntityStoreException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Now we can use entity explorer to check our newly created web service entity.
Our newly created web service is not fully configured yet, we have to add circuit policy on it. Next post will describe how to add circuit policy briefly. Happy coding))

Comments

Popular posts from this blog

8 things every developer should know about the Apache Ignite caching

Any technology, no matter how advanced it is, will not be able to solve your problems if you implement it improperly. Caching, precisely when it comes to the use of a distributed caching, can only accelerate your application with the proper use and configurations of it. From this point of view, Apache Ignite is no different, and there are a few steps to consider before using it in the production environment. In this article, we describe various technics that can help you to plan and adequately use of Apache Ignite as cutting-edge caching technology. Do proper capacity planning before using Ignite cluster. Do paperwork for understanding the size of the cache, number of CPUs or how many JVMs will be required. Let’s assume that you are using Hibernate as an ORM in 10 application servers and wish to use Ignite as an L2 cache. Calculate the total memory usages and the number of Ignite nodes you have to need for maintaining your SLA. An incorrect number of the Ignite nodes can become a b...

Tip: SQL client for Apache Ignite cache

A new SQL client configuration described in  The Apache Ignite book . If it got you interested, check out the rest of the book for more helpful information. Apache Ignite provides SQL queries execution on the caches, SQL syntax is an ANSI-99 compliant. Therefore, you can execute SQL queries against any caches from any SQL client which supports JDBC thin client. This section is for those, who feels comfortable with SQL rather than execute a bunch of code to retrieve data from the cache. Apache Ignite out of the box shipped with JDBC driver that allows you to connect to Ignite caches and retrieve distributed data from the cache using standard SQL queries. Rest of the section of this chapter will describe how to connect SQL IDE (Integrated Development Environment) to Ignite cache and executes some SQL queries to play with the data. SQL IDE or SQL editor can simplify the development process and allow you to get productive much quicker. Most database vendors have their own fron...

Using Apache Ignite thin client - Apache Ignite insider blog

From the version 2.4.0, Apache Ignite introduced a new way to connect to the Ignite cluster, which allows communication with the Ignite cluster without starting an Ignite client node. Historically, Apache Ignite provides two notions of client and server nodes. Ignite client node intended as lightweight mode, which does not store data (however, it can store near cache), and does not execute any compute tasks. Mainly, client node used to communicate with the server remotely and allows manipulating the Ignite Caches using the whole set of Ignite API’s. There are two main downsides with the Ignite Client node: Whenever Ignite client node connects to the Ignite cluster, it becomes the part of the cluster topology. The bigger the topology is, the harder it is for maintaining. In the client mode, Apache Ignite node consumes a lot of resources for performing cache operations. To solve the above problems, Apache Ignite provides a new binary client protocol for implementing thin Ignite cl...