Search This Blog

Adding Header in Service and Reference in BPEL 2.0 and BPEL 1.1 SOA - SOAP


simple test case with soapUI which adds an username and a message as HTTP header to the  service invocation.  In a second testcase I will mock this service in soapUI and BPEL will invoke this service and set an extra HTTP header property.



SOAP - BPEL



First step is to add a property to the binding.ws element of the service in the composite.xml. Add a property with name oracle.webservices.http.headers and as value the HTTP headers you want to use in BPEL
<property name="oracle.webservices.http.headers">username,message</property>


Next step is to define some BPEL variables for those HTTP Headers


In the receive activity of the BPEL process we can use fromProperty to copy the HTTP header property value to the BPEL variable. 

Do this in the BPEL source mode. 

BPEL 2.0


BPEL 1.1

  <receive>
  <bpelx:outputProperty name="username"    variable="usernameVar"/>
  <bpelx:inputProperty name="message"    variable="messageVar"/>
  </receive>


Now you can use these variables in BPEL, I will use these vars in the return message.

Let's invoke the service from soapUI, we need to set the HTTP header properties with their values.


















When we want to invoke a reference service and we also want to set some HTTP header properties.

We need also need to set the http.headers property on the binding.ws element on the reference in the composite.xml

<property name="oracle.webservices.http.headers">username,message,message2</property>


On the invoke of the reference service we need to use the toProperty and set the BPEL vars to these HTTP header properties.

BPEL 2.0

















BPEL 1.1 

  <invoke>
    <bpelx:inputProperty name="username"    variable="usernameVar"/>
  <bpelx:inputProperty name="message"    variable="messageVar"/>
  <bpelx:inputProperty name="message2"    variable="messageVar2"/>
</invoke>

When we test it again in soapUI we can see the invoke request of the soapUI mockservice,
 this contains the HTTP headers which we set in the BPEL process.






ExecutorService - Java - Parallel execution

ExecutorService - Java - Parallel execution    


import java.util.concurrent.ExecutorService;

import java.util.concurrent.Executors;




                  ExecutorService executor = Executors.newFixedThreadPool(2);
                     
                        Runnable worker1 = new accumulator();
                        executor.execute(worker1);
                     

                        Runnable worker2 = new claim();
                        executor.execute(worker2);
                 

                        executor.shutdown();
             
                        // Wait until all threads are finish
                        while (!executor.isTerminated()) {
                         
                        }




    public class accumulator implements Runnable {
                    @Override
                    public void run() {
                        try {
                         
                        } catch(Exception e){
                            e.printStackTrace();
                        }
                    }
    }
   
   
    public  class claim implements Runnable {
                    @Override
                    public void run() {
                        try {
                     
                        } catch(Exception e){
                            e.printStackTrace();
                        }
                       
                    }
    }


XREF Usage in SOA ( Select - xref:lookupXRef , Add - Update - xref:populateXRefRow )

XRef Usage:

( Select,Add and Update)


Xref Table Name : CLR

Name : "InterfaceName" , "LastRunDate"

Select Xref :


Syntax :


xref:lookupXRef(xrefLocation as string, xrefReferenceColumnName as string,
xrefReferenceValue as string, xrefColumnName as string, needAnException as
boolean) as string
Example :

xref:lookupXRef("CLR.xref","InterfaceName","CLR022","LastRunDate",true())


Add - xref:populateXRefRow :



xref:populateXRefRow(xrefLocation as string, xrefReferenceColumnName as string,
 xrefReferenceValue as string, xrefColumnName as string, xrefValue as string, mode
 as string) as string
Parameters

  • xrefLocation: The cross reference table URI.
  • xrefReferenceColumnName: The name of the reference column.
  • xrefReferenceValue: The value corresponding to the reference column name.
  • xrefColumnName: The name of the column to be populated.
  • xrefValue: The value to be populated in the column.
  • mode: The mode in which the xref:populateXRefRow function populates the column. You can specify any of the following values: ADD, LINK, or UPDATE. 
Example :

xref:populateXRefRow("CLR.xref","InterfaceName","CLR022","LastRunDate",xp20:format-dateTime(xp20:current-dateTime(),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01].[f001]'),"ADD")


Update :


xref:populateXRefRow("CLR.xref","InterfaceName","CLR022","LastRunDate",xp20:format-dateTime(xp20:current-dateTime(),'[Y0001]-[M01]-[D01] [H01]:[m01]:[s01].[f001]'),"UPDATE")