Wednesday, April 20, 2016

How to create AIA CAVS Simulator

AIA CAVS SIMULATOR CREATION 
Composite Application Validation System (CAVS) is part of the Application Integration Architecture Foundation Pack and with CAVS you can test your SOA Composites like SOAPUI or the SOA Test Suite.


Click “GO” in Composite Application Validation System.
1. Under Definitions, Click on Create Simulator.

2. Enter the Name of the Simulator(can be anything)


3. Paste the Complete SOAP- envelope request Message (which will be expecting from the Business Service(OSB)/Invoke Activity(BPEL) inside “<cavs:CAVSRequestInput_1>” .

4. Paste the Expected response below(Mock Response) inside “<cavs:CAVSResponseOutput_1> “.
And Click “Save and Next”.

5. In the Next page Click on Generate Xpath.
 6. After that we will be able to see Xpath Selection below the Expected Response Message.

Select any one as “Node Key”and Click “Save And Return”.
Once we Hit the CAVS from our Business Service, the Xpath will be compared with the Simulators and gives us the corresponding response.
Note : 
CAVS URL to Invoke from Business Service/AIAConfiguration :

http://Host:Port/AIAValidationSystemServlet/syncresponsesimulator

Its really easy to change from Stub(CAVS) to actual endpoint with redeployment.
Goto AIA console:- http://Host:Port/AIA
Click on AIA Configuration and enable/disable the checkbox. Then click on "Reload".



Saturday, April 16, 2016

Alert vs Log vs Report in OSB

We have 3 out-of-box options for reporting in OSB, below are the differences between them. We can choose one of them based on our requirement.

Log:
  • One of the basics way of logging in the Oracle Service Bus is adding Log Action in every corner of your proxy service.
  • Your Proxy service might look something like below,


When really debugging a service it’s usually a matter of “what goes in” and “what goes out” and where did my transformation go wrong. So instead of flooding your services with Log Actions, OSB gives an alternate option of enabling Execution tracing(You can find it on each service on the Operational Settings tab, called execution and message tracing).
  • Once we enable the Execution Tracing, the log file will show the full content of MessageContextImpl in every step (stage, route, etc) of the service. The MessageContextImpl holds are the variables like $body, $operation, $inbound and $header you need. – Only Problem in this option is we will end up in logging everything in the server. – Extremely easy to configure but little difficult to track the message in server logs.- Performance impact will be there since all the data is written into one single log file.
Not my preferable option. Since its difficult to track what you want in huge flat file(Server log)

Alert:
  • An alert action in a pipeline is configured to raise alerts when such predefined conditions are encountered.
  • You can also configure email and JMS alert destinations to receive a notification of the alert, and send the details to the alert recipient in the form of payload.
  • Pipeline alerting can also be used to detect errors in a message flow.


Report:
  • Reports mainly used for Track/Monitor the inbound and outbound messages in the proxy services.
  • We can add a Report action in our Request-Response pipeline of our service.
  • The expression field holds the part we actually want to trace – Usually the $Body or Specific Content of the Body element.
  • The Key Name is best used for your reference and let you easily search later on. Which is identical throughout all service calls in the business process. – Correlation Id or Specific element from the body which we can use for tracking during production.
  • We will be able to query all messages in a process or match them based on below categories,
    • Inbound Service Name (the name of the pipeline)
    • Error Code
    • Report Index (key/value pairs)
    • Date-Time

My preference is to use "Report" since you have more control on monitoring the data.

Friday, March 4, 2016

Produce JMS Message to weblogic console using java code

Use the below code to produce a Message in JMS queue using Java code. You can alter the code for lot of automations.

import java.util.Hashtable;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class QueueProducer
{
 // JNDI context factory.- its default
 public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";

 // JMS context factory- JNDI Name.
 public final static String JMS_FACTORY="jms/aia/TestResourceCF";

 // Queue JNDI.
 public final static String QUEUE="jms/aia/AIA_TEST_REQ_IN_JMSQ";

 private QueueConnectionFactory qconFactory;
 private QueueConnection qcon;
 private QueueSession qsession;
 private static QueueSender qsender;
 private Queue queue;
 private static Queue replytoqueue;
 private static TextMessage msg;

 public void init(Context ctx, String queueName)
    throws NamingException, JMSException
 {
    qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
    qcon = qconFactory.createQueueConnection();
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queue = (Queue) ctx.lookup(queueName);
qsender = qsession.createSender(queue);
    msg = qsession.createTextMessage();
    qcon.start();
 }


 public static void send(String message) throws Exception {
    msg.setText(message);
// Replytoname rn=new Replytoname(); //Optional
// Queue replyToQueue = rn.getreplyto(); //Optional
// msg.setJMSReplyTo(replytoqueue); //Optional
// msg.setStringProperty("_wls_mimehdrContent_Type","text/xml; charset=UTF-8"); You can set any JMS Properties Here
// msg.setJMSCorrelationID("testConnectivity");
    qsender.send(msg);
 }

 public void close() throws JMSException {
    qsender.close();
    qsession.close();
    qcon.close();
 }

 public static void main(String[] args) throws Exception {
  InitialContext ic = getInitialContext();
    QueueProducer qs = new QueueProducer();
    String test="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/> <soapenv:Body/></soapenv:Envelope>"; //XML Message
    qs.init(ic, QUEUE); // Open the Queue Session
    send(test); // Produce the message
    qs.close(); // Close the session
 }

 private static InitialContext getInitialContext()
    throws NamingException
 {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
    env.put(Context.PROVIDER_URL, "t3://Host:port"); // Your server credentials
    env.put(Context.SECURITY_PRINCIPAL, "weblogic");
    env.put(Context.SECURITY_CREDENTIALS, "password");
    return new InitialContext(env);
 }
}

Abort instances in EM Console using Java code soa 11g

Basically whatever we see in EM console and whatever do in EM console can be achieved via JAVA code too(using the facade API's). Below is the sample code to abort the instance for any composite in EM console by passing the instance id.

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Hashtable;
import javax.naming.Context;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.util.CompositeInstanceFilter;
import oracle.soa.management.facade.CompositeInstance;
import java.util.List;

public class abortInstance
{
public static void main(String arg[]) throws Exception
{
Hashtable jndi = new Hashtable();
jndi.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndi.put(Context.PROVIDER_URL, "t3://Host:port");
jndi.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndi.put(Context.SECURITY_CREDENTIALS, "password");

jndi.put("dedicated.connection","true");
Locator locator = null;
String instanceID="4432123"; /// pass the composite Instance Id you want to Abort
try
{
locator =LocatorFactory.createLocator(jndi);
CompositeInstanceFilter filter =new CompositeInstanceFilter();
filter.setId(instanceID);
List<CompositeInstance> compositeInstances = locator.getCompositeInstances(filter);
((CompositeInstance)compositeInstances.get(0)).abort();
System.out.print("Instance aborted Successfully: "+instanceID);
locator.close();
}catch(Exception e)
{
locator.close();
e.printStackTrace();
}
finally {
        try {
            if (locator != null){                
            locator.close();            
            }
             } catch (Exception e) { }
    }
}

}

The same code can altered with other functions like delete the instance as well.

Thursday, March 3, 2016

BEA-380000 "Request Entity Too large" Error In OSB

While invoking external systems with help of  Business service, sometimes we might get error like below in the logs,
BEA-380000: Request Entity Too large or
BEA-381304:  <Exception in HttpTransportServlet.service: java.io.IOException: java.net.SocketException: Broken pipe

Even though the size of the XML is too small we might get this error because of Chunked streaming mode.

To eliminate these error,
Go to the configuration of the business service
Go to the HTTP Transport tab
Disable “Use Chunked Streaming Mode"

EBF and EBS in SOA 11g

In AIA, we have lot of terms like EBO,EBM,EBS,EBF,ABCS,etc.. Lets look at the difference between EBF and EBS, when do we need EBF?EBS?

Before that, we need to have a basic understanding on EBO and EBM.

EBO and EBM:
An EBO is the definition for a standard business data object and is composed of reusable data components. It supports the loose coupling of systems in Oracle AIA and eliminates the need for one-to-one mappings of the disparate data schemas between each set of systems. An EBO represents business concepts such as a customer, a sales order, a payment, and so forth. EBOs can be considered as application-independent representations of key business entities.

In simple Words, An EBM is the message format that is specific to the input or output of an EBS operation.

EBS:

  • An EBS provides the generic operations that an EBO should have. Enterprise Business Services (EBSs) are the centerpiece of the AIA Reference Architecture by enabling the Loose-coupling of Requesters with Actual Service Providers.
  • An EBS is coarse-grained and performs a specific business activity or business task and is either an Activity Service or Data Service. 
  • Basically EBS's are the routing services.


EBF:
  • An Enterprise Business Flow (EBF) is used to implement a business activity or a task that involves leveraging capabilities available in multiple applications.
  • An EBF is needed when an enterprise business service (EBS) operation needs to be implemented with a set of tasks and involves invoking of multiple services.
  • So basically EBF will take care of the logics and EBS will do the routing to respective providers.
  • An EBF involves only system-to-system or service-to-service interactions and does not include any activity that requires human intervention.
  • In a canonical integration, the EBF is an implementation of an EBS operation and calls other EBSs. 
  • An EBF never calls an ABCS or application directly. EBF is always encapsulated by EBS.


Similarities:
  • Both operate only on EBMs.
  • Both are external application-independent.(Means both interact within AIA level.)
  • Both are developed at the same time of life cycle.
  • Both works only on single operation.

Monday, February 8, 2016

How to Read MDS File content using Java code - SOA 11g

We can use the below Java Code to connect with MDS database & retrieve the content based on file name and display it as a text.

import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import oracle.mds.config.MDSConfig;
import oracle.mds.config.PConfig;
import oracle.mds.core.*;
import oracle.mds.naming.PackageName;
import oracle.mds.naming.ResourceName;
import oracle.mds.persistence.stores.db.DBMetadataStore;
import oracle.mds.query.*;
import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLDocument;
import org.w3c.dom.Document;

public class RetrieveMDSContent
{
public static void main(String args[]) throws Exception
{
   String MDSFileName="AIAConfigurationProperties.xml"; // MDS File Name
   String connName="MDSConnectionName"; //Dont change it
        MDSInstance mdsInstance = null;
        DBMetadataStore store = getMDSDBHandle();
        PConfig pConfig = new PConfig(store);
        MDSConfig config = new MDSConfig(null, pConfig, null);
        mdsInstance = MDSInstance.getOrCreateInstance(connName, config);
        XMLDocument xmlDoc = null;
        List list = findResource(mdsInstance, MDSFileName, true);
        for(Iterator iterator = list.iterator(); iterator.hasNext();)
        {
            ResourceName rn = (ResourceName)iterator.next();
            mSession = mdsInstance.createSession(new SessionOptions(IsolationLevel.READ_COMMITTED, null, null), null);
            MetadataObject mo = mSession.getMetadataObject(rn.getAbsoluteName());
            String textContent = getDocAsXML(mo.getDocument());
            System.out.print(textContent); // Display the content
        }
    }

    public static String getDocAsXML(Document doc)
        throws Exception
    {
        TransformerFactory tfactory = TransformerFactory.newInstance();
        Transformer xform = tfactory.newTransformer();
        javax.xml.transform.Source src = new DOMSource(doc);
        StringWriter writer = new StringWriter();
        javax.xml.transform.Result result = new StreamResult(writer);
        xform.transform(src, result);
        System.out.print(writer.toString());
        return writer.toString();
    }

    public static List findResource(MDSInstance mdsInstance, String regExpr, boolean stopAtFirstMatch)
        throws Exception
    {
        List rnList = new ArrayList();
        Pattern pattern = Pattern.compile(regExpr);
        findRecursively(mdsInstance, pattern, null, rnList, stopAtFirstMatch);
        return rnList;
    }

    private static void findRecursively(MDSInstance instance, Pattern pattern, String pName, List rnList, boolean stopWhenFound)
        throws Exception
    {
        PackageName packageName = null;
        if(pName != null)
            packageName = PackageName.createPackageName(pName);
        List list = queryMDS(instance, packageName);
        for(Iterator iterator = list.iterator(); iterator.hasNext();)
        {
            ResourceName rn = (ResourceName)iterator.next();
            Matcher matcher = pattern.matcher(rn.getAbsoluteName());
            boolean matchFound = matcher.find();
            if(matchFound)
            {
                rnList.add(rn);
                if(stopWhenFound)
                    break;
            }
            if(rn.isPackageName())
                findRecursively(instance, pattern, rn.getAbsoluteName(), rnList, stopWhenFound);
        }

    }

    public static List queryMDS(MDSInstance mdsInstance, PackageName packageName)
        throws Exception
    {
        if(packageName == null)
            packageName = PackageName.createPackageName("/");
        NameCondition condition = ConditionFactory.createNameCondition(packageName.getAbsoluteName(), "%");
        ResourceQuery query = QueryFactory.createResourceQuery(mdsInstance, condition);
        Iterator contents = query.execute();
        List resources = new ArrayList();
        if(contents == null)
            return resources;
        while(contents.hasNext())
        {
            QueryResult result = (QueryResult)contents.next();
            if(result.getResultType() == oracle.mds.query.QueryResult.ResultType.PACKAGE_RESULT)
            {
                PackageResult pack = (PackageResult)result;
                resources.add(pack.getPackageName());
            } else
            {
                DocumentResult doc = (DocumentResult)result;
                resources.add(doc.getDocumentName());
            }
        }
        return resources;
    }

    public static DBMetadataStore getMDSDBHandle()
        throws Exception
    {
        DBMetadataStore store = new DBMetadataStore("mds_user","mdspassword", "jdbc:oracle:thin:@XXXX:1521/servicename", "soa-infra");
        return store;
    }

    private static MDSSession mSession = null;

}


Use the attached library Jar files to run this Java code.

Monday, February 1, 2016

How to make Lock and Edit button visible in weblogic console

Sometimes in change center of weblogic console, the "Lock & Edit" button wont be visible.
To make it appear again,
Navigate to Preference - > Uncheck "Automatically Acquire Lock and Activate Changes".





And Click on Save. NO NEED TO RESTART.



Wednesday, January 20, 2016

Invoking a web service with Username Password using Credentials Key store - OSB 11g

To invoke a web service protected with Username/Password, Follow the below steps,
We are going to use username-password from Credentials store created in EM console.

1. We will create a key with username-password in EM console.

Open EM console. Navigate to Weblogic Domain -> Security -> Credentials





We have to create the new Key under "Oracle.wsm.security"
Enter the username password like below.
Name of the key can be anything.















2. Now we can use this Key in OSB inside the business service,

Login to sbConsole.

Create a business service. Enter the service Name and select the WSDL web service.





































After creating business service you might get an error(if the wsdl have a security policy already).











In this case, just go to Policies under Businsess Service configuration, And click on Add Compatible or add this policy "oracle/wss_username_token_client_policy". 

If there are more policies, Please remove other policies which are not necessary (But first need to click 
on update button)
























After adding the policy , you can see one more tab called "Security". Navigate to security tab and provide the key information over there.










After providing the key. Click on update and activate the session.

Wednesday, January 13, 2016

Run ant commands in Putty | weblogic server

To Run ant commands in weblogic server. First you need to set the environment variables, only then we can run the commands.
If you don't set the environment variables, you will get error as below,

...bin]$ ant -f build.xml

-bash: ant: command not found

To set, please go to the below path
Oracle/Middleware/wlserver_10.3/server/bin
and run the setWLSEnv.sh like below,

. ./setWLSEnv.sh



Monday, January 11, 2016

How to check the SOA Version Installed in your weblogic server

To check the SOA Suite Version installed in your server.

Please follow the below steps.
- Login to Putty.
- Run command ./soaversion.sh from location $SOA_ORACLE_HOME/bin 

Location will look something like below,





And the Result will display the complete SOA Suite version details.