Thursday, 24 October 2013

Deploying ADF BC SDO Service in oracle java cloud

In this post i will try to explain the process of deploying the ADF BC SDO service in oracle java cloud (PAAS). There are couple of pre-requisties to follow this post, they are
1) Oracle java cloud account to deploy the web service.
2) HRModelSDOService application.

I had used the Jdeveloper version 11.1.1.7 in all screen shots except in step 13 and 14 (where i had used 11.1.2.4). All other steps almost similar in both the verions.
Let us see the steps required to achieve this,


  • Unzip the HRModleSDOService.zip to HRModelSDOService folder.
  •  Open the application in jdeveloper. 

  • If you get a warning for migration of project, Click Yes on “Do you want to migrate these files”.
  • Expand the HRModelSDOService and right click and select configurations on HRSdoAppModule.

  • We have to change the JDBCDataSource value of all the three app modules. Select each module and click on Edit. 


  • Change the Datasource name to “database” (as this the JNDI name of cloud database).


  • Repeat the above step for the remaining two app module configurations (HRSdoAppModuleShared, HRSdoService).
  • Click ok on Manage Configurations window.


  • Right click on the HRModelSDOService and click on project properties.



  • Select  the Deployments tab and delete the existing profile and create a new profile with   Archive Type = Business Components Service Interface. Name  = HRModelSDOService



  • Click on the application menu of the HRModelSDOService application and select Application Properties.



  • Go to Deployments and delete the existing deployments and create a new deployment profile with Archive Type = EAR File, Name = HRModelSDOService



  • Go to Application assembly of the new created deployment profile and select Middle Tier and EJB.




  • Select weblogic under Deployment, Click on ok and select only “Application Policies” check box on the deployment window (unselect all the others). Click ok.



  • Open Application Resourcesà Descriptors à META-INFà weblogic-application.xml



  • This file should have the following content, if it has any duplicate entiries delete them.



  • Save All. Now we are ready to generate the ear and deploy. Select the Application menu à Deploy à HRModelSDOService



  • Select Deploy to EAR option and click on Finish.



  • Get the ear path from the deployment log.



  • Log into java cloud service and click on Deploy New. Select the Ear file and click on Deploy.
  • Verify the Deployment job status in the status message; once it is completed we can access the deployed web service. Get the URL of the deployed application from Test application link.





Thursday, 3 October 2013

REST service in OSB - Creating a WSDL Proxy for REST Service

In this post we will see how to consume a RESTful service in OSB and create a WSDL proxy for the same so that that the WSDL clients can consume.

Steps:
1. Consuming the REST Serivce in OSB and creating a business service.
2. Creating a WSDL proxy and connecting routing it to the REST business Service.


Consuming REST service in OSB:

1. Create a Oracle Service Bus configuration Project in OEPE- eclipse.


2. Create a Oracle Service Bus Project


3. Create folders business services, proxy services, jars, wsdls under project.

4. Create a Business service under business services folder.

5. Select Messaging service in the General tab and select the request and response message types in as per your requirement.





6. Add the Rest service url in the Transport tab.

7. Leave the remaining tabs with defaule values.
8. You can test the busieness service(if you want) by exporting the project from eclipse and importing in OSB console.

Creating WSDL Proxy for REST service:

1. Create a WSDL which will be used to create the proxy for the REST business service.
2. The WSDL should contain the input, output and operation that it exposes. Please find the below WSDL for reference (it show only the operation and bindings).



3. Create a new proxy service and select Service Type as WSDL web service and browse and select the WSDL that is created in the previous step.




4. Leave all other tabs/fields as default values and click on messag flow tab.

5. Create a conditional branch under the proxy service and set the condition for branch as the method argument from the input variable. (in the example that is depicted here the http method name is passed in the input)



6. Add a branch and for handling GET requests.



7. Add a Route node under GET brancha and pipeline pair which will route to the REST business service which is created earlier.



8. Now we have to prepare the request pipeline to invoke the REST service. The REST url for the GET method will be http://hostname:port/context/event/1 where /1 is the relative uri which will fetch the event details with event id 1.

9. So we need to set http-method (value GET), and relative-URI value (the id value that is passed to the WSDL proxy service.

10. Add an insert action which will set the http-method.



11. Add an assign action which will get the id from the wsdl input and set it to a variable (id).



12. Set the relative URI.



If your REST service is expecting the query string( like http://hostname:port/context/event?id=1) instead of relative URI then set the query string as mentioned below, 

fn-bea:inlinedXML(concat('', concat('', 'id=',$id, ''), '
'))
13. Now the request part is completed. 

14. If your REST service returns the xml you can directly map it to the reponse of the proxy service(after performing required transformations).

15. In this example my REST service returns JSON response so i need to convert it into the xml format which we will see in the below steps.

16. In the response pipeline add an Assign activity which will assign the response body to a variable 'jsonRes'.



17. Now we need to convert the json reponse to xml format. For this we need the JSONXMLConverter.jar which has two methods to conver json to xml and vice versa. For this jar to work we need to copy following jar under the lib folder of your OSB domian.

  • commons-beanutils-1.8.3.jar
  • commons-beanutils-bean-collections-1.8.3.jar
  • commons-beanutils-core-1.8.3.jar
  • commons-lang3-3.1.jar
  • ezmorph-1.0.6.jar
  • json-lib-2.4-jdk15.jar
  • junit-4.10.jar
  • xom-1.2.8.jar
18. Add a java callout activity which will call the json2xml() in JSONXMLConverter.jar and pass the input as jsonRes and assign the output to 'xmlRes' variable.


19. Replace the response body node contents witht xmlRes.




20. Now we can test the proxy service from OSB console or from SOAP UI (we can get the exposed wsdl of proxy from OSB console).

21. We can configure the other http methods in the same manner.

Wednesday, 8 May 2013

Auto refreshing a component/page in ADF

Scenario: Refreshing a page automatically after a specified interval.

Solution: 
To acheive the auto refresh feature on a page in ADF we have to use the af:poll. 

Step 1: Use in the jspx.

                       id="pollTimer"
                       pollListener="#{backingBeanScope.backing_stockinfo.onPollTimerExpired}"
                       interval="2000"/>





  • Specify the interval in milli seconds.
  • pollListener is the listener method which will be called every time after the specified interval.
Step 2:In a bean write the poll Listner method which will have the logic to refresh the page.


public void onPollTimerExpired(PollEvent pollEvent) {
         //Custom logic to update the data/data control.
        //Refresh the table/component.
        AdfFacesContext.getCurrentInstance().addPartialTarget(getT1());
  }


  • If we have requirement to refresh different components at different time intervals (like 2mins for a table, 5mins for a graph) then we can implement it by creating variable in view scope which will hold the last updated time and we can check it against the current time, and if the difference exceeds the specified time then we can refresh the component.
  • Below code snippet shows refreshing two tables at two different times (the Alert table will be refreshed after every 2mins and the symbol table will be refreshed after every 5mins.

 public void onPollTimerExpired(PollEvent pollEvent) {
        //Refresh for Alert table.
        Long lastRequery = (Long)AdfFacesContext.getCurrentInstance().getViewScope().get("lastRequery");
      //Updating data control
        ApplicationModule am = ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
        ViewObject alertVO  = am.findViewObject("AlertRO1");
        alertVO.executeQuery();
        AdfFacesContext.getCurrentInstance().addPartialTarget(getT2());

        //Refresh for symbol table.
        if(lastRequery ==null || lastRequery <= System.currentTimeMillis()){
           
            ViewObject symbolVO = am.findViewObject("StockDataViewRVO1");
            symbolVO.executeQuery();
            AdfFacesContext.getCurrentInstance().addPartialTarget(getT1());
            Calendar c=Calendar.getInstance();
            c.add(Calendar.MINUTE, 5);
            AdfFacesContext.getCurrentInstance().getViewScope().put("lastRequery",c.getTimeInMillis());
        }
    }



Sunday, 5 May 2013

Executing custom logic in BPM human task

Scenario: Excuting a custom logic in BPM human task before calling the action of BPM services. 
Let us think that we want some custom logic to be executed on click of Approve/Reject button in BPM human task. 

Solution:
To achieve this, we need to follow the below two steps,

Step 1: Write a managed bean and a submit method and write your custom code first and then the below code to invoke the BPM services.

public String submit(){
       // Custom Logic goes here.............................

        //Invoking BPM Services
                    Map map =
                        FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
                    oracle.bpel.services.workflow.worklist.adf.InvokeActionBean invokeActionBean =
                        (oracle.bpel.services.workflow.worklist.adf.InvokeActionBean)map.get("invokeActionBean");

                    String result = invokeActionBean.invokeOperation();
                     return result;
    }


Step 2: Configure this method as action method in the jspx for the Approve/Reject/Ok button.

                                               text="#{wf:getResourceValue('OK', 'bindings.customActions')}"
                                               disabled="#{!bindings.OK.enabled}"
                                               action="#{pageFlowScope.managedBean.submit}"
                                               partialSubmit="false"
                                               visible="#{wf:isCustomActionAvailable('OK', 'bindings.customActions')}"
                                               id="ctb1">
                       
                                     value="bindings.OK"/>
                     


Monday, 25 February 2013

Clearing the data objects in Oracle BAM

Problem:
The common problem that we all will face in development/testing of  BAM reports is that we may need to reset/clear the values of the data objects.

Solution: 
There is a utility called icommand which we can use to solve the above problem.

go to the bin directory of BAM, (cd /oracle/fmwhome/Oracle_SOA1/bam/bin)

Eg: 
1) clearing data object
icommand -cmd clear -name "path_of_the_dataobject" -type dataobject

path_of_the_dataobject = "/Samples/Call Center/"

2) Deleting the data object

icommand -cmd delete -name TestDO 

Using this icommand we can export the reports/data objects from one BAM server to the another BAM server (please refer to the icommand documentation for usage of specific commands). 

Sunday, 17 February 2013

Creating an LOV which is detached from entity model/DB in ADF


      This post explains how to create an LOV which is detached from entity model (no database or business component validation for insertion should happen on change of the drop down value).


         To demonstrate this, let us consider a login screen which will have user name, password as input text fields and a drop down to select the county whose value will be stored in session for later use (the list of countries should be populated from database but the selection in the UI should not have effect on the database).

1) Let us create a view object for country table.
2) Once the view object is created , Create the LOV for country Id by clicking on attributes à List of values.





3)     In loginpageDef.xml add an executable (iterator).


4) Go to structure of loginpageDef.xml and add variables under executables

5) Create a variable countryIdVar under the variables


6) Now in login.jspx, drag and drop countryName from data controls

7)   Give the proper values (base data source as variables and list data source as data control.

Friday, 15 February 2013

Accessing selected value of LOV (drop down) in ADF

Problem:
How to access the selected value of a LOV (drop down) in managed bean (java class) programatically.

Solution:

1) Write a value change listener for the LOV.
2) Get the Iterator of the LOV from bindings.
3) Get the current select row from the iterator by passing the newly selected value which you can get from the valueChangeEvent object.

Please find the code snippet below,


        BindingContext bctx = BindingContext.getCurrent();
        oracle.binding.BindingContainer bindings = bctx.getCurrentBindingsEntry();


        DCIteratorBinding iterBind = (DCIteratorBinding)bindings.get("CourseVO1Iterator");
        Row rw = iterBind.getRowAtRangeIndex(((Integer)e.getNewValue()).intValue());

        String courseId= rw.getAttribute("CourseId").toString();
        String courseName= rw.getAttribute("Name").toString();

Thursday, 14 February 2013

Error while creating web service proxy from wsdl in Jdeveloper


I am getting the below error while creating the web service proxy in JDeveloper,
oracle.jdeveloper.webservices.model.WebServiceException: Error creating model from wsdl 

I am using Jdeveloper 11.1.1.6.0


Problem:

The problem is in JDeveloper 11.1.1.6.0 (i am not sure about other versions) when you try to create web service proxy in a project which has "ADF Model Runtime" library as a dependency (it is dependent on some other project which has ADF Model Runtime) the proxy creating will fail.

Solution:
Solution 1. Remove the ADF Model Runtime depdency and create web service proxy and then add the dependency again.

Solution 2. Just create an other generic project and create a proxy there and call the proxy.

Solution 3. You can create the web service as a data control in the same project and use it.