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.