Friday, August 25, 2017

Publish action with Error Handling in OSB 11g

There are several ways that we can invoke target service in OSB.
1. Service callout
2. Routing
3. Publish

We use Publish action when you don't need to wait for the response from target service like JMS queue, producing files or invoking one way services.(kind of fire and forget)
If we use the publish action, even though there is some error in the target service it will not stop the flow. Our flow will just move on to the next activity in the pipeline.

But in some cases we do need to handle the exception in publish, like if the webservice is down.

To catch the error, we need to add Routing Options under publish and make the quality of service to "Exactly once".

Publish with "exactly once" is architecturally equivalent to synchronous service invocation and it will be no longer a "fire and forget" invocation.

Publish action will become Synchronous call in one another case as well, if we are invoking another OSB proxy service (on Local, or on HTTP) the thread will be blocked until we get the response.



Wednesday, August 2, 2017

How to Invoke Async BPEL from Sync BPEL | Is it possible to add wait activity in Sync BPEL.?

Is it possible to invoke a Asynchronous BPEL from Synchronous BPEL.?
Yes. Its possible. 

Is it possible to add "Wait" activity in Sync BPEL.?
Yes. Its possible.

While you are trying to invoke a Async BPEL from Sync BPEL, you might notice that the invoke activity is success. But the receive activity will be in Pending state as show below.


Same for wait activity as well.

And also you might notice an error message in dashboard as below.

"Waiting for response has timed out. The conversation id is null. Please check the process instance for detail. "

To resolve this, you need to change the transaction property(in composite.xml) in Sync BPEL as,

<component name="BPELProcessXX" version="1.1">
<implementation.bpel src="BPELProcessXX.bpel"/>
<property name="bpel.config.transaction">requiresNew</property>
<property name="bpel.config.oneWayDeliveryPolicy" type="xs:string"
              many="false">async.persist</property>
</component>


Monday, June 5, 2017

How to deploy MDS artifacts (WSDL and Schemas) through Jdeveloper


  1. Create a new application (Generic Application)
    2. Name the application as MDSApp (it can be anything) doesnt matter
     3. Create a Project (name it anything)
     4. Right Click on the project, Select "Project Properties".
    5. Navigate to deployment and Click on New
     6. Select the Archive type as "JAR File".
    7. Click on contributors and  select the folder (where your mds artifacts are located). The Folder structure in your local should be same as MDS location. Select the folder "apps". And click on Filters, to select the files you want to deploy.

     8. Click on application(not project), deploy-> New Deployment profile.
     9.Select SOA Bundle.
    10. Name the deployment profile(leave it as default)
     11. Click on dependencies and select the "archive1" (the jar file you have created in step 6) and Click on "Ok".
     12. Now deploy the application (Not the project) into the server.

Friday, June 2, 2017

Cannot find composite composite.xml in sar file

Problem: 

While deploying the Composite from Jdeveloper, you get the below error.

HTTP error code returned [500]
Error message from server:
There was an error deploying the composite on soa_server1: Error occured in processing sar file sca_testProject_rev1.4.jar before transfering into MDS store. Please make sure the sar file is a valid jar file.: Cannot find composite composite.xml in sar file : sca_testProject_rev1.4.jar. Abort deployment..

Check server log for more details.
Error deploying archive sca_testProject_rev1.4.jar to partition "default" on server soa_server1
####  Deployment incomplete.  ####


Reason:

If you open up the .jar file in deploy folder of the composite, you could find nothing in it or just scac.log and scac_out.xml files will be there. Ideally, your .jar file should contain all the files and folders of the composite.
Note: there is no problem with your composite.xml or any of your other files except ".jpr"

Root cause:

The problem is because of .jpr file in your composite, ".jpr" file help us create the jar file while deploying it to server. Normally if you open the .jpr file you could see below tag
 <hash n="oracle.jdeveloper.deploy.dt.DeploymentProfiles"> (Specifically "<hash n="profileDefinitions">" under that) which will describe what files will be part of .jar file.


Somehow your ".jpr" file is corrupted for your composite.

Solution:

To solve this issue-  Create a new composite (just the project skeleton) with exact same name and just copy the ".jpr" to your old composite which was not getting deploying. That should work.

Note: While creating the new project, create the project with same composite name, BPEL name, namespace as well.

Wednesday, May 31, 2017

How to Pass BPEL Variable(String Variable) into XSLT in SOA

In BPEL:


<from expression="ora:doXSLTransformForDoc('xsl/Xform_ResourceEBM_to_ResourceRequestABM.xsl', $ResourceReqMsg.ResourceEBM,'counter',$PCounter)"/>

In XSLT:

   <xsl:param name="counter"/>
   <xsl:template match="/">---> Add the parameter just above the template 

How to execute SQL Query in Xquery / Assign Activities in OSB

You can execute SQL Statements without creating the JCA adapter/Business service in OSB. For a simple queries, you can use use

<details>{fn-bea:execute-sql('jdbc/XYZDataSource',xs:QName('FileDetails'),'select Filename,Filelocation from TABLENAME where Columnname=?')} </details>


Output will be something like,

<details>
<FileDetails>
<Filename>ABC</Filename>
<Filelocation>XYZ</Filelocation>
</FileDetails>
</details>

Error while invoking OSM Webservice from BPEL - javax.xml.soap.SOAPException: Bad response: 401 Unauthorized

While Invoking OSM webservice from BPEL, we might get below error if we are not sending the username and password.

successfully due to: javax.xml.soap.SOAPException: javax.xml.soap.SOAPException: Bad response: 401 Unauthorized

we can resolve this error by adding the username,password and security policy to the reference adapter. While we are creating the reference adapter with OSM webservice, by default there will be 2 bindings(OrderManagementWebServiceJMSPort and OrderManagementWebServicePort). But we can ignore the OrderManagementWebServiceJMSPort  and add the policy reference only to OrderManagementWebServicePort as shown below in composite.xml.


<reference name="OrderManagementWS"
               ui:wsdlLocation="oramds:/{MDSURL}/OrderManagementWS.wsdl">
<interface.wsdl interface="http://xmlns.oracle.com/communications/ordermanagement#wsdl.interface(OrderManagementWSPort)"/>
<binding.ws port="http://xmlns.oracle.com/communications/ordermanagement#wsdl.endpoint(OrderManagementService/OrderManagementWebServicePort)"
                    location="{OSMURL}"
                    soapVersion="1.1">
<wsp:PolicyReference URI="oracle/wss_username_token_client_policy"
                                 orawsp:category="security"
                                 orawsp:status="enabled">
</wsp:PolicyReference>

<property name="javax.xml.ws.security.auth.password"
                      type="xs:string" many="false" override="may">osmpassword123</property>
<property name="javax.xml.ws.security.auth.username"
                      type="xs:string" many="false" override="may">osm-username</property>
<property name="weblogic.wsee.wsat.transaction.flowOption"
                      type="xs:string" many="false">WSDLDriven</property>
<property name="weblogic.wsee.wsat.transaction.version"
                      type="xs:string" many="false">DEFAULT</property>
</binding.ws>

</reference>

Friday, May 26, 2017

Retry in fault policy is not working - BPEL

Recently faced a issue where the retry in fault policy was not working for few composites. I verified the fault polices in both composites and all look same.
<Action id="ora-retry">
<retry>
<retryCount>3</retryCount>
<retryInterval>10</retryInterval>
<retryFailureAction ref="ora-rethrow-fault"/>
<exponentialBackoff/>
</retry>
</Action>

Then i realized something to do with Composite.xml. Adding the below property in component is making it work.

 <component name="ABC">
        <implementation.bpel src="ABC.bpel"/>
        <property name="bpel.config.transaction">requiresNew</property>
        <property name="bpel.config.oneWayDeliveryPolicy">sync</property>
    </component>

Note: While creating the Synchronous bpel composite's by default it will be"Required". 

Monday, February 6, 2017

How to release the Sequence lock in Mediator SOA 11g (Oracle Mediator Resequencer)

Message Sequencing is often a requirement in Enterprise application where you need to provide updates to the target application in some certain sequence. For example, courier status for an customer. It has to reach the customer in certain sequence like (Received, Shipped, Dispatched, Delivered, Confirmed, etc..). Even though the source application is providing the status in sequential manner, there is a possibility in integration layer that 3rd update may fail and the fourth one will be received by the customer. Once you reprocess the error instances the 3rd update will be received by the customer which will be of no sense (Received, Shipped, Delivered, Dispatched, Confirmed, etc..).
So we have to maintain the same sequence like it came from the source system.

So in SOA 11g, Oracle Mediator Resequencer which guarantees to maintain the desired message sequence in a reliable and robust manner.

You can implement the resequencer in Mediator by just selecting from the drop down box like below.


In the Picture, the sequence is applied on the account id. So for that account, whatever the update it came first will be delivered first. If some error happens in between, all the other updates to that account will be on hold.

Now, coming to the topic. How to release the lock if there is any, 
  1. Normally these mediator would have been implemented with fault policies such as Manual Recovery. In that case go to EM console, navigate to Faults and Rejected Messages and enable "Show only recoverable faults". Click on "Recovery" icon and retry the instance.


2. If you don't want to retry, you have an option of abort as well.

3. If nothing works, directly login to the Database with SOAINFRA schema. And use the below queries to  unlock the sequence.

select *  from mediator_group_status where status!=0;
update mediator_group_status set status=0 where status!=0;

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.