Monday, 23 November 2015

Invoking a cross domain webservice from jquery

I am going to share the jquery code that I used to invoke a cross domain webservice (for more details on cross domain requests, please click here)

We need to pass following couple of important fields while invoking the cors webservice.

  • dataType: 'json'
  • crossDomain : true
  • and I have the basic authentication as well for my webservice, so I am passing xhrFields.

xhrFields: {   
    withCredentials: true
  }


Here is the full jquery code snippet, 


$.ajax({
 
url:'URL_TO_MY_WEBSERVICE',

headers: {
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Headers':'Origin, X-Requested-With, Content-Type, Accept',
'Access-Control-Allow-Methods':'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Max-Age': '86400',
'Access-Control-Allow-Credentials':true,
        'Authorization':setAuthHeader("userName", "password"),
        'Content-Type':'application/json'

    },xhrFields: {   
    withCredentials: true
  },
type: 'GET',
dataType: 'json',

crossDomain : true



Note: My webservice requires the users to be authenticated with http basic authentication. You can see the Authorization uses a method called setAuthHeader() which intern uses btoa() function to generate the base 64 encoded string which is required for basic authentication. Please find the setAuthHeader() source code below,

function setAuthHeader(username,password){
var cred = username +":"+ password;
var basic = btoa(cred);
var hashstr = "Basic "+basic;
return hashstr;

}

Parallel and Serial assignments in Oracle BPM human tasks

In this post I will discuss on parallel and serial assignments of human tasks in oracle bpm.

Parallel assignment:

  • This option will be used when we need parallel approval for a specific task. 
  • Users jack, rose and andy should need to approve/reject the task in parallel.
  • We can specify the list of users as a comma separated string in human task assignment.
  • We can decide the vote outcome by specifying condition on the percentage of the outcome by the parallel participants.
  • In the below example I am setting the outcome as reject even if one of the users rejects (My requirement is it is considered as approved when all the users approve it, if any one user rejects and the task should be considered as rejected).
Serial assignment:
  • Serial assignment is just the task goes to each mentioned users in sequence for approval.
  • users jack, rose and andy should need to approve/reject the task in sequence.
  • We can configure the serial assignment in such way that if any of the users rejects the task then task will not move to the next users. It will directly by considered as rejected.
  • Click on the pencil icon in the assignment tab of the human task.

Monday, 20 July 2015

equals() method in Comparator Interface in java

Why there is equals() in Comparator Interface when it is already defined in Object class which is super class of all classes in Java??

The only reason that the equals() is defined again in the Comparator Interface is just to defined some different documentation of equals() in Comparator interface. The equals() method in Comparator interface has some extra documentation which is specific to Comparator functionality.

Have a look at the documentation of equals() method in Compartor interface here.


Thursday, 7 May 2015

Handling CDATA in BPM Web Service call

The most common problem that we face while invoking a web service which expects some xml as a string in CDATA from oracle BPM/BPEL.
Like 

"<![CDATA[<UnderwriterAssignment><ApplicationID>XXXXXXXX</ApplicationID><Underwriter>XXXX</Underwriter></UnderwriterAssignment>]]>"

The above string has to be passed to the webservice as a string.

The problem here is the engine will convert the < and > to &lt; and &gt; while invoking. But the service may not be coded in such a ways that it accepts like that and the web service invokation will fail.

To resolve this, 

  • Prepared (assign) the string that needs to be sent as CDATA.
  • someString = "<UnderwriterAssignment><ApplicationID>ATL620007</ApplicationID><Underwriter>satishs</Underwriter></UnderwriterAssignment>"
  • On the service call use ora:toCDATA() to convert it into proper CDATA without encoding
  • like ora:toCDATA(someString).
This will not encode the string and it will pass as it is.

Tuesday, 14 April 2015

Issue while deploying case data form in oracle ACM

I am working on a case management POC in BPM version 11.1.1.7.

I had generated the case data form UI project and trying to deploy the project. But the data form in case is not coming up. The case data UI project is not part of the ear/war that is getting generated.

So I had included the case data UI project manually into the ear deployment profile. But while deploying the ear I am getting the below error,

ClassNotFoundError :oracle.bpm.casemgmt.client.forms.servlet.CaseFormServlet

To resolve this issue, I have to manually add the below jars case UI project 

oracle.bpm.casemgmt.implementation.jar
oracle.bpm.casemgmt.interface.jar

You can find these jars under jdevhome\jdeveloper\soa\modules\oracle.bpm.runtime_11.1.1


Deploy the generated ear project and it works.

Wednesday, 1 April 2015

Reusable process in Oracle BPM

In this post I just want to jot down my findings about the reusable processes in oracle BPM.

  • Reusable Process starts with a None start event.
  • And there won't be initiator after that.
  • If any initiator node is added, or the start event is changed, this no longer becomes a reusable process.
  • A Reusable Process can be called from a 'Call' Activity
  • Most importantly the execution data will be carry forwarded from the calling process to the reusable process.
    • Means the attachments, user comments that are added in the calling process will be available in the reusable process.




In the above sample processes, the first process will the second reusable process using the call activity.
Whatever the documents uploaded or comments entered in the first human task in the first process will be available for the first human task in the second process. So it is like only one process is getting executed with respect to the execution data.

Monday, 30 March 2015

Using for loop in XSL

By default xsl supports the for-each functionality which will iterate over the number of elements in source xml.
But what if we need something like for loop in normal programming language??
like for (int i=0;i<10 ;i++)

Solution:
We can achieve the above requirement with the help of callable template as described below,


 <xsl:template name="party">
    <xsl:param name="count"/>
    <xsl:param name="xml"/>

    <xsl:if test=" $count > 0">
            <name>
                  <xsl:value-of select="$xml/name"/>
          </name>
     </xsl:if>     
      <xsl:call-template name="party">
            <xsl:with-param name="count" select="$count - 1"/>
            <xsl:with-param name="xml" select="/"/>
        </xsl:call-template>  
  </xsl:template>          
       
   
Call the above template like this,

        <xsl:call-template name="party">
            <xsl:with-param name="count" select="6"/>
            <xsl:with-param name="xml" select="/"/>
        </xsl:call-template>           
                   
 
Above code creates the tag six times.

In this you can see how to access the source xml in the templates.
As you will not have direct access to the source xml in the callable template we need to pass it as parameter and use in the template.