Wednesday, July 18, 2012

Creating a wlfullclient.jar - Weblogic

Creating a wlfullclient.jar for JDK 1.6 client applications from weblogic server

    Change directories to the server/lib directory.

    cd WL_HOME/server/lib

    Use the following command to create wlfullclient.jar in the server/lib directory:

    java -jar wljarbuilder.jar

    You can now copy and bundle the wlfullclient.jar with client applications.

Creating a wlfullclient5.jar for JDK 1.5 client applications:

    Change directories to the server/lib directory.

    cd WL_HOME/server/lib

    Use the following command to create wlfullclient.jar in the server/lib directory:

    java -jar wljarbuilder.jar -profile wlfullclient5

    You can now copy and bundle the wlfullclient5.jar with client applications.

Monday, July 16, 2012

Retrieving the XML payload in Java Servlet

Retrieving the XML payload in Java Servlet:

If the request content type is text/xml and the method is POST, we can use the below code to retrieve the xml payload in servlet.

    public void doPost(HttpServletRequest request,
                       HttpServletResponse response) throws ServletException,
                                                            IOException {
        response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        BufferedReader br = request.getReader(); 
            String line = null; 
            StringBuffer inputXML = new StringBuffer(); 
            PrintWriter pout = response.getWriter(); 
             
            while ((line = br.readLine()) != null) { 
                inputXML.append(line); 
            } 
            br.close();
           
            System.out.println("Input "+inputXML);
           
        java.io.InputStream sbis = new java.io.StringBufferInputStream(inputXML.toString());

        javax.xml.parsers.DocumentBuilderFactory b = javax.xml.parsers.DocumentBuilderFactory.newInstance();
        b.setNamespaceAware(false);
        org.w3c.dom.Document doc = null;
        javax.xml.parsers.DocumentBuilder db = null;

        try {
            db = b.newDocumentBuilder();
            doc = db.parse(sbis);
        } catch (Exception e) {
            e.printStackTrace();
        }
     
        org.w3c.dom.Element element = doc.getDocumentElement();
       
        String empName=getPayloadValue(element, "EmpName");
        String empNo=getPayloadValue(element, "EmpNo");
     
      
       String output="<EmployeeCollection xmlns=\"http://xmlns.oracle.com/HttpAdapter/InvokeServlet/InvokeServlet\"><Employee><EmpName>"+empName+"</EmpName><EmpNo>"+empNo+"</EmpNo><EmpAge>27</EmpAge></Employee><Employee><EmpName>"+empName+"</EmpName><EmpNo>"+empNo+"</EmpNo><EmpAge>28</EmpAge></Employee></EmployeeCollection>";
       out.write(output);
        out.close();
    }

    public String getPayloadValue(Element taskPayloadElement, String nodeName){
       
     String output= "";  
    NodeList nodeList = taskPayloadElement.getElementsByTagName(nodeName);
    if(nodeList!=null && nodeList.getLength() > 0){
    Element myElement = (Element)nodeList.item(0);
    output= myElement.getFirstChild().getNodeValue();
    }
    return output;
   
}

Java utility to test the business rule with out deploying to server – Oracle SOA Suite

Java utility to test the business rule with out deploying to server – Oracle SOA Suite

This blog will explain how to use the Java API to test the Oracle Business rule with out deploying to server in Oracle SOA Suite. This utility will read the input from the XML file and generate the output XML.

Download the utility OracleBusinessRuleTester.rar

Steps to execute the utility from JDeveloper:

  • Unzip OracleBusinessRuleTester.rar and import the project to JDeveloper
  • Open OrderRequestRuleTester.java in JDeveloper
  • Change the value OrderLineRequestDictionary141008 with the package name of the JAXB classes e.g. com.rule.test (in my case the package name is OrderLineRequestDictionary141008).
  •   The package name can be seen in the .rule file, open the .rule file in text editor and search for JaxbFactType

Wednesday, July 11, 2012

JAX-WS Webservice returning empty output - Oracle SOA Suite 11g

JAX-WS Webservice returning empty output - Oracle SOA Suite 11g

When we invoke the JAX-WS web service created from JDeveloper 11g and deployed to  Oracle SOA Suite 11 returns the empty output.

 Issue:

@WebResult annotation was missing in the generated web service method.

Resolution:

Add the @WebResult annotation as shown below
@WebResult (targetNamespace="targetNamespace",name="OutputParameterName", partName="partName")


O/P: 

Sunday, July 8, 2012

Changing the reference endpoint of a Composite through JAVA – Oracle SOA Suite


Changing the reference endpoint of a Composite through JAVA – Oracle SOA Suite

Sometimes we may need to change the endpoint value of a Composite reference, the same can be done through the EM console by following the below blog.

Another way to accomplish this is to use the Java API; this blog will explain how to use the Java API to change the reference endpoint of a Oracle SOA Suite composite. This approach will work in both Oracle SOA Suite 11g and Oracle SOA Suite 12c.

This update is not a cluster-aware; remember that you must repeat the same process for each managed server of your environment.


CRUD operations with the Entity variable – Oracle SOA Suite

CRUD operations with the Entity variable in Oracle SOA Suite:

In Oracle SOA Suite, we can use the Entity variables to perform the CRUD operations on the database. Entity variable will have the reference to the SDO enabled web services like ADF BC web service.
In Oracle SOA Suite we can expose the View objects (VOs) in ADF BC as SDO’s. SDOs enable you to modify business data regardless of how it is physically accessed.

For each Entity variable, a Unique Key (e.g. Primary key) must be associated with the corresponding Element.

Entity Variables automatically propagate data object changes through the ADF BC layer via "Change Summary" operations and can be used in BPEL by means of a partner link of either an ADF-BC binding or SOAP (WS) binding reference to your ADF BC service.

We can use the following activities Create Entity, Bind Entity and Remove Entity to perform the CRUD operations.

Bind Entity:

This activity enables you to select the entity variable to act as the data handle. This action select the row from the datasource, the update/Delete operation can be performed on the selected data.  

Create Entity: 

This activity enables you to create an entity variable. This action creates a row in the Datasource. 

Remove Entity: 

This activity enables you to remove an entity variable. This action removes the row from the datasource.

Follow the previous blog (Invoking a ADF-BC service from the SOA Composite – Oracle SOA 11g) to create and deploy the ADF BC SDO service.

Create a BPEL process which will take the employee details as input/output as shown below.


Create the web service parnerlink in the composite.xml by consuming the ADF BC service URL created in the previous blog. 

Friday, June 29, 2012

Enable Discovery Cache to Avoid Long Delay during Login to EM console – Oracle SOA Suite 11g

Enable Discovery Cache to Avoid Long Delay during Login to EM console in Oracle SOA Suite 11g

Logging into Enterprise Manager of Fusion Middleware Control 11g (fmwctl) takes a long time, the fmwctl discovery is always performed as part of login.  For installations with thousands of targets (e.g. Composites), fmwctl discovery may take 45-60 seconds. This time is expected because EM discovery Mbeans need to be invoked for every target. If the number of fmwctl monitored targets (e.g. Deployed Composites) increases, the login time will go up as well.
Solution is to cache the discovery results in the servlet context and use it for subsequent logins. This discovery result will be shared by all the fmwctl users. This will still require the entire discovery to be done at least once.
New parameters are added to enable/disable and to control the usage of the cached discovery results.  
  • If the caching is enabled, fmwctl will use the cached discovery results.
  • The default setting is "not use the cached results"
We have observed this issue in Oracle SOA Suite version 11.1.1.5.0 and Oracle suggested the patch 13251077 to enable the fmwctl discovery cache.

Steps to enable fmwctl discovery cache:

  1. Upgrade to FMw 11.1.1.6 or apply available patch 13251077 for your version.
    If applying patch 13251077, set ORACLE_HOME to MW_HOME/oracle_common before applying.
  2. Navigate to fmwctl System mBean browser.