Tuesday, July 29, 2014

How to user correlations to Order messages in BPEL

How to user correlations to Order messages in BPEL


This small example will show how to use correlations to wait for a specific message to execute a second message, regardless of the order. Suppose that we have to operation one will insert and the other one will update a record. We need to execute the update first but not necessarily we are going to receive the insert first. When systems are distributed is hard to predict which message will arrive first.

  1. First step we are going to create an schema
Element ‘Type’ will contain the operation that we want to use, example INSERT or UPDATE
Element ‘Correlation ‘ will include a key that will group similar messages for the same operation
  1. Then we will create an EDN using the schema created befoer , we will call this EventEmail.edl
  2. I will create a bpel process (with the correlation code), one Mediator that will be instantiated by the EDN, one SOAP interface and a second mediator that will group all events assigned from the EDN and the SOAP interface.
SOAP interface is only for easy testing purposes
Composite structure will look like this
  1. Is important at composite level to set the property “bpel.config.reenableAggregationOnComplete”, this will allow us to reuse the same correlation as soon as one is closed

  1. Create the following BPEL , is important to notice that receiveInput will receive a correlation and OnMessage will receive the same correlation

  1. In the BPEL process we are going to create a correlation set with the following properties

Initiate for the first receive of the process, with an string property


Suppose we have a message
<ns1:email>
<ns1:type>INSERT</ns1:type>
<ns1:correlation>12</ns1:correlation>
</ns1:email>

The previous configuration will assign the value 12 as a correlated property so all messages receiving 12 will be group together.

Finally we are going to add an skip condition that indicates that only INSERT messages will be handled in the receive, so all messages that are not insert will be handled by the PICK

contains($inputVariable.payload/ns1:type,'INSERT')
  1. Finally we are going to add the same setup to the PICK activity without the skip condition and with NO on instantiate
  2. For testing We are going to send one message this two messages first UPDATE
<ns1:email>
<ns1:type>UPDATE</ns1:type>
<ns1:correlation>12</ns1:correlation>
</ns1:email>

After that insert
<ns1:email>
<ns1:type>INSERT</ns1:type>
<ns1:correlation>12</ns1:correlation>
</ns1:email>

The output will be the following,

As we can see the messages will be order and we can execute the logic properly

Monday, April 28, 2014

Extracting encrypted password of a weblogic datasource

In some cases you might need to know the password of an already setup datasource.  If you go to the weblogic console url your'll just see **** symbols. If you look directly into the xml file the password is not visible either, so where do you go from here.  You could use a WLST script similar to the following. Please consider file paths as well as host and weblogic credentials are hardcoded but you could easily replace those. See below an example.


#This WLST script will extract the encrypted password of 
#any given weblogic datasource
from weblogic.security.internal import *
from weblogic.security.internal.encryption import *
from xml.dom import minidom

# Path where the wncrypted pwd is (replace path with your jdbc xml file path)
doc = minidom.parse('/oracle/fmwhome/user_projects/domains/dev_bpm/config/jdbc/mds-soa-jdbc.xml')
pwd = doc.childNodes[0].childNodes[3].childNodes[7].firstChild.data

#Get password of connectionpool (replace path with your domain security path)
encryptionService = SerializedSystemIni.getEncryptionService("/oracle/fmwhome/user_projects/domains/dev_bpm/security")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)

# Remove unneeded characters
preppwd = pwd.replace("\\", "")

# Decrypt the password
psd=clearOrEncryptService.decrypt(preppwd)
print('Unencrypted password -> ' + psd)

Thursday, April 3, 2014

common UCM payloads GenericSOAPPort

11.   Before start using the GenericSOAPPort is important that security is added to the request you can easily do this with a policy “oracle/wss_username_token_client_policy” or add a username and password in the SOAP UI for testing


22.  Check in a new document


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ucm="http://www.oracle.com/UCM">
   <soapenv:Header/>
   <soapenv:Body>
    <GenericRequest xmlns:ns0="http://www.oracle.com/UCM" xmlns="http://www.oracle.com/UCM" webKey="cs">
<ns0:Service IdcService="CHECKIN_NEW">
<ns0:User/>
<ns0:Document>
<ns0:Field name="dDocTitle">test56.pdf</ns0:Field>
<ns0:Field name="dDocType">Document</ns0:Field>
<ns0:Field name="dSecurityGroup">Public</ns0:Field>
<ns0:File name="primaryFile" href="test51.pdf">
<ns0:Contents>
[base 64]
</ns0:Contents>
</ns0:File>
</ns0:Document>
</ns0:Service>
</GenericRequest>
   </soapenv:Body>
</soapenv:Envelope>

33. Retrieve document id  dID from the response from the previous call and use it as input parameter, “GET_FILE”

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ucm="http://www.oracle.com/UCM">
   <soapenv:Header/>
   <soapenv:Body>
            <ucm:GenericRequest webKey="cs">
         <ucm:Service IdcService="GET_FILE">
            <ucm:Document>
            <ucm:Field  name="dID">6404</ucm:Field>
            </ucm:Document>
         </ucm:Service>
      </ucm:GenericRequest>
   </soapenv:Body>
</soapenv:Envelope>


44. Approve a document

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ucm="http://www.oracle.com/UCM">
   <soapenv:Header/>
   <soapenv:Body>
    <GenericRequest xmlns:ns0="http://www.oracle.com/UCM" xmlns="http://www.oracle.com/UCM" webKey="cs">
<ns0:Service IdcService="WORKFLOW_APPROVE">
<ns0:Document>
<ns0:Field name="dID">6402</ns0:Field>
</ns0:Document>
</ns0:Service>
</GenericRequest>
   </soapenv:Body>
</soapenv:Envelope>


55.  Scan a document after approved and indexer successfully run the GET_SEARCH_RESULT

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ucm="http://www.oracle.com/UCM">
   <soapenv:Header/>
   <soapenv:Body>
      <ucm:GenericRequest webKey="cs">
         <ucm:Service IdcService="GET_SEARCH_RESULTS">           
            <ucm:Document>
 <ucm:Field  name="QueryText">dID = `6405`</ucm:Field>
            </ucm:Document>
         </ucm:Service>
      </ucm:GenericRequest>
   </soapenv:Body>
</soapenv:Envelope>

Wednesday, December 18, 2013

How to zip/base64 string response on Oracle Service Bus

How to zip/base64 string response on Oracle Service Bus


                When you are working with huge results like big XMLs or Json  is handy to compress the OSB output. As an example if you are connecting to an Android device you can send the data compressed and then let Android decompress it.

Here is an example of how to accomplish this task in Oracle Service Bus.

1.    1.   First we need to create a class that will compress a String.

public class ZipContent {
    public ZipContent() {
        super();
    }

    public static String zipme(String content) throws IOException {


        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(out);
        gzip.write(content.getBytes());
        gzip.close();

        byte[] bytes = out.toByteArray();
        return  Base64.encodeBase64String(bytes);
       
    }
}

2.       2. Add your library to a jar file and add it in the resource folder of your Service Bus project
3.      3. Create a new java callout with your body

Method: ZipContent.zipme
Expression: $body
Result value: body









4.    4.   Your results will be compresses and in base64



Tuesday, November 12, 2013

AQ burst in OSB and notification in BPEL when burst is complete

Create Maximum Thread Constraints


11. On weblogic console Navigate to Environment > Work Managers > New

22.  Define a new maximum threads constraint
3. Define the count number to two


Create a work Manager

11.   Navigate to Environment > Work Managers New
22.   Select work manager

3. Add a name to the work manager
14. Add the server targets that will use the work manager and click finish
25. After created select it from the work managers list

16. Assign the maximum threads constraint option


BPEL notification process


For this BPEL process we are going to use a pattern call aggregation with correlation sets. Basically we are going to correlate all the bpel processes using a batchid and after 15 seconds of not receiving aq messages the process will be closed so we can notify the client that all invoices are consumed.

11.  Create a new schema accepting two parameters an invocieid and batch. Batch is the value that will be used as correlation





12. Create a one way process passing the “request” of the schema as input
23.  BPEL process will  have the following characteristics
a.       Create a while loop when a variable call count < 1
b.      Initialize variable count with 1
c.       Create a pick, If you receive a new message use correlation batch explained in next step
d.      If no more requests are received timeout adding count as value of 1
                                                               i.      In this step you  can add the notification to the customer

14. To create a correlation go the left bar as show in screen and click add

15. Create a correlation naming it “correlationAggregate” add a new property with Name “batch” and string type.    
a.       Assign the received message as the request type and query to bath element of the schema as shown in the screenshot
16. Make sure that “Create Instance” is checked on the receiveInput .

7. Add the correlation set to the “receiveinput” and set the property Initiate to “yes”


18. Add the correlation se to the “onMessage” setting the property initiate to “no”


BPEL process with wait


11. Create a synchronous process that will have the following activites
a.       Call the BPEL notification process
b.      Call a wait of 3 seconds only to see the dealy on each process



OSB burst program


1.1. Create a new proxy service that will call the sync wait process created in the previous step. This proxy service requires to have the following
a.       Throttling state enabled
b.      Maximum concurrency 2
c.       Throttling queue  2


12.  Create a dequeue business service  and cal the service created in step 1
a.       Make sure to add the work manager “wm/aqconsumer”  in the dispatch policy



1.3.  Business service will look like this
a.       Make sure to pass the batch id always the same during the burst



Results

                Disable the OSB process, enqueue some messages


You will see that every 2 seconds 2 processes are picked up and triggered. Also the aggregate process will continue stop and send a notification 15 seconds after the last message is received.









Wednesday, November 6, 2013

How to ssh with no password


1.      1.  ssh-keygen –t rsa on server1
hit return on password
2.      2.  ssh-copy-id –I .ssh/id_rsa.pub user@server2
3.       3. on server2
a.       chmod 700 .ssh
b.      chmod 640 .ssh/authorized_key
4.      4. Finally you can test it ssh user@server2

Thursday, October 17, 2013

How to configure OAF environment

1.      Set a local variable JDEV_HOME to your jdeveloper installation in my scenario is “G:\jdevoa\jdevhome\jdev”
2.      Go to $FND_SECURE and copy your environment “.dbc” file into your  local environment “$JDEV_HOME\..\..\jdevbin\oaext\dbc_files\secure\FILE.dbc”
3.      Right click on the application and Create a “New OA Workspace”


1.      Select a name for your workspace and make sure that is pointing to $JDEV_HOME\jdev

1.      Select a project name check the option “Use repository at design time” and create a new database connection








1.      On the File Name click browse and select the dbc file that you copied in step 2
a.      Populate your user name , password, application short name and responsibility key
2.      Copy the code you want to modify from the following locations
a.      $AP_TOP/MDS to jdevhome/myprojects
b.      $JAVA_TOP to jdevhome/jdev/myclasses
3.      Refresh your project

1.      Click on the page you want to execute



1.      Depending of what page and what code are you executing is the time that will take to run, it can take a long time so be prepared