Tuesday, November 23, 2010

Integrating Web Services into your ADF Application Part 2

Sorry for the late post but I was constantly travelling and just found some time to finish my second part of integrating web services into your ADF application.

In this demo I have tried to integrate the reporting capabilities that Oracle BI Publisher offers with Oracle ADF through the use of web services.

More specifically, I have used a web service proxy to connect to the PublicReportService BI Publisher web service. Based on the selected employee (rendered using an ADF table), the appropriate employee id is passed to the runReport method of PublicReportService web service. This in turn runs the employee report which creates a pdf report and presents the generated report to the end user.

I have uploaded a complete step-by-step tutorial on how to achieve the above mentioned functionality along with the source code of my demo (ADFBIPublisher).
This tutorial shows you how you can consume an existing web service from your ADF Web Application using a web service proxy. More specifically, how to consume a BI Publisher web service, called PublicReportService, to run a report from your ADF Web Application.

For the purpose of this tutorial, I am using Oracle JDeveloper 11g Version 11.1.1.3.0, Oracle Database 11g Standard Edition Version 11.2.0.1.0, Oracle BI Publisher Version 10.1.3.4.1 and Oracle BI Publisher Desktop Version 10.1.3.4.1. All mentioned software can be downloaded from Oracle Technology Network.

Please note that this tutorial assumes that you have installed Oracle Database 11g Standard Edition with at least the HR sample schema, Oracle BI Publisher Version 10.1.3.4.1 and Oracle BI Publisher Desktop Version 10.1.3.4.1.
Create a Report using BI Publisher
1. Navigate to the Oracle BI Publisher page (http://:/ xmlpserver/) and sign in.
2. Select the Admin tab to access the Administration area.
3. Under Data Sources, click the JDBC Connection

4. Click the Add Data Source button to create a new data source connection to the HR sample Schema. Specify HRDataSource in the Data Source Name, in the Driver Type select Oracle 11g and in the Database Driver Class ensure that oracle.jdbc.OracleDriver is defined. In the connection string, specify the host, port and sid of your installed database (eg. jdbc:oracle:thin:@localhost:1521:orcl). Specify the username and password for the HR schema and click Test Connection. Once you get a successful connection confirmation, click Apply.
5. Click the Reports tab and from the Reports page, click the Shared Folders link.
6. In the “Folder and Report Tasks” pane, select Create a new folder, assign the name Demo to the folder and click Create.
7. Click the newly created folder Demo and from the “Folder and Report Tasks” pane click Create a new report. In the “Enter Report Name” text box, enter Employee and click Create.
8. From the newly create report “Employee” that has been created click the Edit link to edit the report.
9. The first step is to create a data model for our new report. So click the Data Model menu option under the “Report” tree structure and select New.
10. Under “General Settings”, specify the name to be Employee DataSet and ensure that the “Type” is set to be SQL Query. Under the “Details”section, specify the data source to be the HRDataSource that you have created a few steps before. In the SQL Query, click the Query Builder to declaratively specify your SQL query.
11. From the Query Builder window, click the Employees table and it will bring it to the main centre area.
12. We will be needing the JOBS table, as our main table EMPLOYEES has an external reference JOB_ID to the JOBS table (we want to display the actual job name and not an id), so click the JOBS table, EMPLOYEES tables (again) and the DEPARTMENTS.
13. From the EMPLOYEES table, select all the columns except from the JOB_ID, MANAGER_ID and DEPARTMENT_ID. From the JOBS table select the JOB_TITLE column, from the EMPLOYEES_1 table select FIRST_NAME and LAST_NAME and from the DEPARTMENTS table select DEPARTMENT_NAME.
14. Now it is time to define the external references that the EMPLOYEE table has with the other three tables. From the Employees table, to the right of the JOB_ID column, single click on the blank cell next to “A”. Do the same thing with the JOB_ID column in the JOBS table. You should see the relationship being created.
15. Do the same thing for the MANAGER_ID from the EMPLOYEES table with the MANAGER_ID from the EMPLOYEES_1 table, and the same with DEPARTMENT_ID from the EMPLOYEES table with the DEPARTMENT_ID from the DEPARTMENTS table. Once finished, click Save.
16. You should see now in the SQL Query input box the query being populate as follows:

select EMPLOYEES.EMPLOYEE_ID as EMPLOYEE_ID,
EMPLOYEES.FIRST_NAME as FIRST_NAME,
EMPLOYEES.LAST_NAME as LAST_NAME,
EMPLOYEES.EMAIL as EMAIL,
EMPLOYEES.PHONE_NUMBER as PHONE_NUMBER,
EMPLOYEES.HIRE_DATE as HIRE_DATE,
EMPLOYEES.SALARY as SALARY,
EMPLOYEES.COMMISSION_PCT as COMMISSION_PCT,
JOBS.JOB_TITLE as JOB_TITLE,
EMPLOYEES_1.FIRST_NAME as FIRST_NAME,
EMPLOYEES_1.LAST_NAME as LAST_NAME,
DEPARTMENTS.DEPARTMENT_NAME as DEPARTMENT_NAME
from HR.DEPARTMENTS DEPARTMENTS,
HR.EMPLOYEES EMPLOYEES_1,
HR.JOBS JOBS,
HR.EMPLOYEES EMPLOYEES
where EMPLOYEES.JOB_ID=JOBS.JOB_ID
and EMPLOYEES.MANAGER_ID=EMPLOYEES_1.EMPLOYEE_ID
and EMPLOYEES.DEPARTMENT_ID=DEPARTMENTS.DEPARTMENT_ID

Please make the following change to the manager first name and manager last name columns, as the data come from the same table and we have the same column names as with employee first name and last name. The change is highlighted in bold:

select EMPLOYEES.EMPLOYEE_ID as EMPLOYEE_ID,
EMPLOYEES.FIRST_NAME as FIRST_NAME,
EMPLOYEES.LAST_NAME as LAST_NAME,
EMPLOYEES.EMAIL as EMAIL,
EMPLOYEES.PHONE_NUMBER as PHONE_NUMBER,
EMPLOYEES.HIRE_DATE as HIRE_DATE,
EMPLOYEES.SALARY as SALARY,
EMPLOYEES.COMMISSION_PCT as COMMISSION_PCT,
JOBS.JOB_TITLE as JOB_TITLE,
EMPLOYEES_1.FIRST_NAME as MANAGER_FIRST_NAME,
EMPLOYEES_1.LAST_NAME as MANAGER_LAST_NAME,
DEPARTMENTS.DEPARTMENT_NAME as DEPARTMENT_NAME
from HR.DEPARTMENTS DEPARTMENTS,
HR.EMPLOYEES EMPLOYEES_1,
HR.JOBS JOBS,
HR.EMPLOYEES EMPLOYEES
where EMPLOYEES.JOB_ID=JOBS.JOB_ID
and EMPLOYEES.MANAGER_ID=EMPLOYEES_1.EMPLOYEE_ID
and EMPLOYEES.DEPARTMENT_ID=DEPARTMENTS.DEPARTMENT_ID

Before saving our work, please note that we have to manually input a where clause to limit the number of records retrieved by the SQL query to just a single employee record. Please append at the end of the SQL Query the following command:

“and EMPLOYEES.EMPLOYEE_ID = :pEmployeeId”

Click Save.
17. The next thing is to define the parameter pEmployeeId that we have inserted in our SQL Query, so click on the Parameters link and then New.
18. Under “General Settings”, specify pEmployeeId in the Identifier field. In the “Text Setting” area, specify Employee Id in the Identifier field and click Save.
19. Now we are ready to test our report. To test it, click the View link.
20. In the Employee Id enter the value 200. On the left hand side of the View button there is a drop down menu that if you expand you will notice that only Data is available. Because we did not specify a template yet, the only available output option is Data, which is basically xml. We will need this xml data to construct our template, so click View and once the data have been generated, click the Export button.
21. Save the xml data locally (for example on your desktop) and then open Microsoft Office to design the template. Please note that again, I am assuming that you have installed Oracle BI Publisher Desktop Version 10.1.3.4.1 which attaches some BI add-ons in Microsoft Office products. So open Microsoft Office and design your preferred layout for your Employee Report. I have designed a simple report, with the Oracle log and date and page number on the header field, a title and a table to hold my employee details.
22. The next thing to do is to load the xml data that we have downloaded from running our report to Microsoft Word. So click on the Add-Ins ribbon tab, Data and Load XML Data.
23. Select your Employee.xml and click Open.
24. Click OK to dismiss the “Data Loaded Successfully” window. Place your cursor to the empty table cell next to the Employee Id and select from the menu Insert and Field.
25. As you can notice, the field browser window contains all the fields specified in the SQL query that we have defined in our report using BI Publisher. So select Employee Id and click Insert. The EMPLOYEE_ID has been added next to the Employee Id cell.
26. Perform the same thing, but each time inserting the appropriate field to the report. Please note that in our field browser we have FirstName and LastName, however in our report we have Name. So to concatenate first name and last name, just insert the FirstName, hit the space bar once and insert the LastName field. Your report should look as follows:
27. Although our SQL query will return only one record, the field browser assumes that it may return more than one records. So for our template to work, we need to specify a loop, just in case more than one record is returned. To achieve this place your cursor between the “Employee Report” title and the table, and double click the Row element from the field browser. You should see the ROW element inserted.
28. Close the field browser, place your cursor at the beginning of the ROW element, and select from the menu Oracle BI Publisher, Insert and Repeating Group.
29. On the BI Publisher Properties window, click OK. You will notice that it has created a for-each element and an end element between your ROW element.
30. Select the end element and move it to the end of the table.
31. Save the template as a Rich Text Template and name it Employees. You can now close the word file.
32. Access the Oracle BI Publisher application and edit your Employee report under the Demo folder that we have created and click the Layout menu.
33. Under the “Manage Template Files” click the Browse button and browse to the Employees.rtf template that we have just created, click Open and then Upload. You should see the Employees.rtf file uploaded.
34. Having the Layouts menu option selected, click the New button.
35. In the name, specify Employee Template and ensure that the Employees.rtf template is selected in the Template drop down. In the Output Format, make sure that All Formats radio option is selected and click Save.
36. Click the View link once the report has been saved to test our final report. In the Employee Id input field, enter 200. Next to the Employee Template, select from the drop down menu PDF and then click View. Your report should be rendered in PDF format and display the details for employee Jennifer Whalen.
Consume the Report from ADF
1. Open JDeveloper and create a new Application.
2. In the Create Application dialog box, specify the Application Name to be ADFBIPublisher, in the Application Package Prefix field set the value to be demo and in the Application Templates choose the Fusion Web Application (ADF) and click Finish.
3. Close the ADFBIPublisher Overview window as we will not be using it. In the Application Navigator you'll see two new projects now, one called Model and the other called ViewController. Right click the model project and select New.
4. Under the Business Tier category, select ADF Business Components and then from the items select Business Components from Tables and click OK.
5. In the “Initialize Business Components Project”, click on the green add sign Create a new database connection.
6. In the “Create Database Connection” window, specify your database connection details to connect to your HR schema. In the Connection Name, specify HRConnection, in the Username field HR, in the password your HR schema password and ensure that the “Save Password” check box is checked. In the Driver, select thin, and specify the host name where your datanase resides, the SID (in my case it is XE) and the port number (in my case it is 1521). Click Test Connection and if successful, click OK.
7. The “Initialize Business Components Project” window is now populated with the new connection name that we have created. Leave the default SQL Flavor (Oracle) and Type Map (Oracle) and click OK.
8. The “Create Business Components from Tables” wizard starts, with Step 1 being defining your entity objects. In the package, specify demo.model.entities, in the schema make sure that HR is selected and click Query.
9. The query retrieved all available tables and views from our HR schema. We will be working with the Employees tables, so select Employees from the available pane and shuttle it to the selected pane. In the Entity Name, change the default name from Employees to EmployeesEO and click Next.
10. On Step 2 of the wizard, “Updatable View Objects”, specify in the package name demo.model.views and shuttle from the available pane the EmployeesEO to the selected pane. Change the default object name to EmployeesVO and click Next.
11. On the “Read-Only View Objects” step click Next.
12. In the “Application Module” step, ensure that the Application Module is checked. In the package name, specify demo.model.module, leave the default name (AppModule) and click Finish.
13. We have set up our model, now it is time to design our interface. So right-click the ViewController project and select New.
14. Expand the Web Services category, select JSF and from the items select JSF Page. Click OK.
15. In the “Create JSF Page” window, specify the file name to be Employees.jspx, leave the default directory (C:\JDeveloper\mywork\ADFBIPublisher\ViewController\public_html) and ensure that the Create as XML Document (*.jspx) check box is checked. In the Initial Page Layout and Content select Page Template and from the drop down menu select Oracle Dynamic Tabs Shell. Expand the Page Implementation section and ensure that Do Not Automatically Expose UI Components in a Managed Bean is selected and click OK.
16. The Employees.jspx page should be displayed. If not expand your ViewController project, locate your Employees.jspx page and double click it to open it. Ensure that the Employees.jspx page is in design view.
17. There are two ways of working with the UI. The first one is by dragging and dropping items on the actual page and the second way is by using the Structure window. I will be using the second way. So, to ensure that everyone has their structure window enabled select from the menu View and then Structure (alternatively, click Ctrl+Shift-S).
18. The Structure window should appear in the left lower corner of your JDeveloper. In case the Structure window is empty, just click anywhere inside the Employees.jspx page. Expand f:view, af:document, af:form, af:pageTemplate and /oracle/ui/pattern/dynamicShell/dynamicTabShell.jspx faces.
19. From the Component Palette, ensure that ADF Faces is selected and under the Layout section, select Panel Splitter and drag it onto the welcome facet.
20. Expand af:panelSplitter, panel Splitter facets and change the Orientation of the panel splitter (using the property inspector) from horizontal to vertical.
21. From the Layout section of the ADF Faces, drag Panel Collection onto the first facet of the panel splitter and a Panel Tabbed onto the second facet of the panel splitter.
22. From the second facet of the panel splitter, expand af:panelTabbed and click on the af:showDetailItem – showDetailItem 1 and change the text to Employee Details.
23. Expand the Data Controls and under AppModuleDataControl, select the EmployeesVO1 view and drag it over the af:panelCollection – pc1 component and select Table, ADF Read-only Table ...
24. In the “Edit Table Columns” window, select Row Selection, Sorting and Filtering and click OK.
25. Drag the EmployeesVO1 view object onto the af:showDetailItem – Employee Details component (under the panelTabbed component inside the second facet) and select Form, ADF Form ...
26. On the “Edit Form Fields” just click OK.
27. Let’s run the application to see how our Employees.jspx page looks like and what data are being rendered. To run the page, just right click the Employees.jspx page and select Run. This will start the Integrated WebLogic Server, Deploy the application and render it on your default browser.
28. We can see that the Employees.jspx page is divided in two sections. The first section showing a table with all employees and the second section, below the table, the employee details of the selected record above (for example, Steve King). Try clicking on another record from the record, for example Alexander Hunold. The form does not display the details for the selected record. This is because we have not specified that section (basically the form) to listen to any changes in the table component.
29. So to make the form element reflect changes made from the table component, select the af:panelFormLayout under the af:showDetailItem – Employee Details component and using the property inspector select Edit next to the PartialTriggers.
30. In the Edit Property of the PartialTriggers window, expand facet (welcome), panelSplitter – ps, facet (first), panelCollection* - pc1 and select table* - t1 and click Add to selected. You should see the table* - t1 to the selected pane. Click OK.
31. If you right click the page and choose Run you can see that the detail form reflects the details of the above selected master record.
32. You can change the default branding title (Navigation Shell) to something more meanigfull. To achieve this, click the af:pageTemplate tag under the af:form and from the Property Inspector, under the Other section, just change the brandingTitle property from Navigation Shell to ADF/BI Integration. If you run the page once more, you should see the new title being displayed.
33. The next thing is to create a menu that will give the option to the user to run the report that we have created using BI Publisher. So in the first facet under the panel splitter, expand the panel collection and panel collection facets. Right click the menus facet and select Insert inside menus and choose Menu.
34. Having the af:menu – menu 1 item selected, from the property inspector change the text from menu 1 to File.
35. Right click the af:menu – File item and select Insert inside af:menu – File Menu Item.
36. Select the af:commandMenuItem – commandMenuItem1 from the structure window, and from the property inspector change the text from commandMenuItem 1 to Run Employee Report.
37. From the component palette, select ADF Faces and from the Operations section drag a File Download Action Listener onto the af:commandMenuItem – Run Employee Report.
38. Select the af:fileDownloadActionListener from the structure window and using the property inspector, specify the filename to be Employee.pdf.
39. Next to the method property, click the arrow and select Edit.
40. From the Edit Property window, click New.
41. In the Create Managed Bean, specify EmployeesBean as the Bean Name, Employees as the Class Name, demo.view.beans in the package and click OK.
42. From the Edit Property, click New next to the Method drop down to create a new method.
43. In the Create Method dialog, specify runReport as the method name and click OK.
44. Click OK in the Edit Property window.
45. BI Publisher exposes several of its operations as web services. To see what operations are exposed as web services, open a browser to go to your BI Publisher server home page and append to the url /services (http://:/xmlpserver/services). Some of the services are XMLPService, AdminService, PublicProvisiongService etc.
46. Scroll down and locate the service PublicReportService and click on the wsdl link.
47. You should see the PublicReportService wsdl file. Copy the url location as we will use it in the following steps.
48. Back in JDeveloper, create a new project by selecting File, New.
49. From the General categories, select Projects and from the items select Generic Project and click OK.
50. In the Create Generic Project window specify WebServiceProxy as the project name and click Finish.
51. Right click the newly created project WebServiceProxy and select New.
52. From the Business Tier category select Web Services and from the items select Web Service Proxy and click OK.
53. In step 1 (Create Web Service Proxy) click Next and in step 2 of the wizard (Select Client Style) select JAX-WS Style and click Next.
54. In step 3 (Select Web Service Description), in the WSDL Document URL input field, paste the url of the PublicReportService wsdl location that you have copied (http://:/xmlpserver/services/PublicReportService?wsdl) and click Next.
55. In step 4 (Specify Default Mapping Options), specify demo as the package name and demo.types as the root package for generated types and click Finish.
56. As you can see, the wizard has created all java classes necessary to run the specified web service (PublicReportService). We will use these classes from our ViewController project. To actually have access to these generated classes from our ViewController project, we need to define the project dependencies from our ViewController project. So right click the ViewController project and select Project Properties.
57. Select Dependencies and click on the pencil Edit Dependencies.
58. Expand WebServiceProxy.jsp and select the Build Output check box and click OK.
59. In the Project properties click OK. Open the Employees bean that we have auto-created to insert the actual logic of the runReport method. Expand ViewController, Application Sources, demo.view.beans and double-click in the Employees.java file to open it.
60. In the runReport method, insert the following code:

BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iterator = (DCIteratorBinding)bindings.get("EmployeesVO1Iterator ");
Row row = iterator.getCurrentRow();
String employeeId = row.getAttribute("EmployeeId").toString();

PublicReportServiceService publicReportServiceService = new PublicReportServiceService();
PublicReportService publicReportService = publicReportServiceService.getPublicReportService();

ReportRequest reportRequest = new ReportRequest();
reportRequest.setAttributeFormat("pdf");
reportRequest.setAttributeLocale("en-US");
reportRequest.setAttributeTemplate("Simple");
reportRequest.setReportAbsolutePath("/Demo/Employee/Employee.xdo");
ArrayOfParamNameValue pNameValue = new ArrayOfParamNameValue();
ParamNameValue nameValue= new ParamNameValue();
nameValue.setName("pEmployeeId");
ArrayOfString aos = new ArrayOfString();
aos.getItem().add(employeeId);
nameValue.setValues(aos);
pNameValue.getItem().add(nameValue);
reportRequest.setParameterNameValues(pNameValue);

try {
ReportResponse response = new ReportResponse();
response = publicReportService.runReport(reportRequest, "Administrator", "manager1");
outputStream.write(response.getReportBytes());
} catch (Exception e) {
e.printStackTrace();
}


What this code does is that based on the Employee View Iterator, gets the selected row and based on the selected row, obtains the value of the Employee Id. It then calls the PublicReportService web service and requests to run a specific report (Employees report), assigning the employee id parameter. The web services responds back to the caller with the bytes of the actual report that we in turn pass to the outputStream object of the fileDownloadActionListener so that the file can be displayed to the users.

Please note that when prompted import the following classes:

import demo.PublicReportService;
import demo.PublicReportServiceService;
import demo.types.ArrayOfParamNameValue;
import demo.types.ArrayOfString;
import demo.types.ParamNameValue;
import demo.types.ReportRequest;
import demo.types.ReportResponse;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;
import oracle.jbo.Row;
61. Right click Employees.jspx and choose Run.
62. You should see the new menu (File) that we have created being displayed next to the View menu.
63. Select an employee, for example EmployeeId 102 (Lex De Haan) and from the new menu that we have created select File, Run Employee Report.
64. You should be presented with the Employees.pdf file, presenting all employee details of the selected employee.

Tuesday, November 2, 2010

Integrating Web Services into your ADF Application Part 1

As promised, I am uploading the presentation slides (Oracle ADF 11g Enhanced Capabilities & Features) along with a complete step-by-step tutorial on how to integrate Web Services into your ADF Application using a Web Service Data Control along with the source code of my demo (JavaWebService & ADFHelloWorldJava).


Create a Java Class and Expose it as a Web Service
1. In the Applications Navigator, click New Application. Another option is to use the File->New... menu option to create a new application.
2. In the Create Application dialog box, specify the Application Name to be JavaWebService. Notice that the directory changes to match the new name. You can change the C:\JDeveloper\mywork part of the path to create your files in another location.

In the Application Package Prefix field set the value to be demo. In the Application Templates choose the Generic Application and click Next.
3. In step 2 of the Create Application Wizard, specify the Project Name to be HelloWorld and click Finish.
4. Right click the HelloWorld project and select New.

5. Under the General category, select Java Class.
6. In the Create Java Class , specify the Name to be HelloWorld and uncheck the “Constructors from Superclass” and “Implement Abstract Methods” options and click OK.

7. In the HelloWorld.java class, copy and paste the following code:

public String sayHello(String firstname, String lastname){
return "Hello " + firstname + " " + lastname;
}
8. Right click the HelloWorld.java class and select Create Web Service.
9. This initiates the Create Java Web Service Wizard. In the Select Deployment Platform, leave the default platform selected (Java EE 1.5 with support for JAX-WS Annotations) and click Next.
10. In the Generation Option, leave the defaults and click Next.
11. In the Message Format, select SOAP Bindings 1.2 and click Next.
12. In the Methods, make sure that the sayHelo method is selected and click Finish.
13. If you open HelloWorld.java, you will notice that the wizard appended some annotations to the class to expose it as a Web Service. Right click HelloWorld.java and choose Run to deploy it to the Integrated WebLogic Server.
14. Once deployed, you will notice in the WebLogic console a Target URL. This is the url of the deployed HellWorld Web Service. JDeveloper provides you with a Web Service Test Client, so if you click on the url, it will open the test client, allowing you to test the web service.
15. If you enter your name and surname and click Send Request, the web service should respond with a message “Hello name surname”, where name is the name that you have specified and surname is the surname that you have specified in the web service call.
16. Before proceeding to the next step and creating our Fusion ADF Web Application that will consume this web service that we have just created, please make sure that you have copied the target url of the deployed web service as this will be needed in the next steps.

Create an ADF Fusion Application and a Web Service Data Control to Consume the HelloWorld Web Service
1. In the Applications Navigator, click New Application.

2. In the Create Application dialog box, specify the Application Name to be ADFHelloWorldJava. Notice that the directory changes to match the new name. You can change the C:\JDeveloper\mywork part of the path to create your files in another location.

In the Application Package Prefix field set the value to be demo. In the Application Templates choose the Fusion Web Application (ADF) and click Finish.
3. In the Application Navigator you'll see two new projects now, one called Model and the other called ViewController. Right click the model project and select New.
4. Under the Business Tier category, select Web Services and then from the items select Web Service Data Control.
5. In the Create Web Service Data Control Wizard, specify the name for the Data Control to be HelloWorld and the URL to be the url that you have copied before. Please note that at the end of the url, you need to append ?wsdl to specify the WSDL file of the Web Service, and click Next.
6. In the Data Control Operations, shuttle the HelloWorldService to the selected pane and click Finish.
7. Right click the ViewController project and select New.
8. Under the Web Tier category, select JSF and then from the items select JSF Page.
9. In the Create JSF page, specify the File Name to be HelloWorld.jspx and make sure that the “Create as XML Document(*.jspx)” option is checked. Under Initial Page Layout and Content select Blank Page and click OK.
10. Expand the Data Control section and drag the sayHello method onto the HelloWorld.jspx page as an ADF Parameter Form.
11. On the Edit Form Fields, just click OK.

12. As you can see, ADF automatically created an ADF form based on the method’s input parameters and included a submit button to call the web service.
13. The HelloWorld Web Service returns a String. To display the output of the web service, just drag the String output from the Data Control below the sayHello button as an ADF Output Text.
14. Right click the page and choose Run.
15. Provide a value for sayHello_arg0 (Firstname) and a value for sayHello_arg1 (Lastname) and click the sayHello button.
16. The HelloWorld Web Service is called and returns a message “Hello name surname”, where name is the name that you have specified and surname is the surname that you have specified in the web service call.


I will be publishing "Integrating Web Services into your ADF Application Part 2" which will include calling a Web Service programmatically using a web service data control in the next couple of days, followed by a tutorial on how to secure your ADF Application using ADF Security.

Engjoy!

Wednesday, October 27, 2010

Oracle ADF Enhanced Capabilities & Features

Following a recent workshop that I have conducted with Oracle Cyprus, "JDeveloper 11g - ADF Workshop for Developers" , I presented some enhanced capabilities and features of ADF. More specifically, how do you enable ADF Security and how do you integrate web services into your ADF Application.

I will be uploading the presentation along with all the demos by the end of next week, so please visit the blog again.

Tuesday, May 4, 2010

BEA-101371: Error deploying to IntegratedWebLogicServe

When running a .jspx page from JDeveloper11g i get the following errors:

BEA-101371, There was a failure when processing annotations for application C:\Documents and Settings\user\Application Data\JDeveloper\system11.1.1.2.36.55.36\o.j2ee\MyApp\ModelWebApp.war. Please make sure that the annotations are valid. The error is org.apache.myfaces.trinidad.webapp.ResourceServlet
Caused By: java.lang.ClassNotFoundException: org.apache.myfaces.trinidad.webapp.ResourceServlet
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
Truncated. see log file for complete stacktrace


The reason of this behaviour is that there is an application deployed on the integrated server that is miss configured.

One approach to solving this issue is to undeploye the miss-configured application. This can be done using the preonfigured application Server connection from JDeveloper (IntegratedWLSConnection). Expand the IntegratedWLSConnection Application Server Connection (View menu, Application Server Navigator), locate the application, right click the application and choose undeploy.

The second approach is to recreate you system11.1.1.2.XX.XX.XX. One easy way to do this is first close JDeveloper. Then right click My Computer, choose properties, and select the advanced tab. Click on Environment Variables and under the user variables, create a new variable called JDEV_USER_HOME. In the value field, specify the path where you want your system11.1.1.2.XX.XX.XX system folder to be created. When you start JDeveloper, it will prompt you if you would like to migrate from another version. Choose No.

Friday, April 9, 2010

FTP Adapter As A Service Component

The following tutorial illustrates the usage of the file adapter as a service component.

1. In the Applications Navigator, click New Application. Another option is to use the File->New... menu option to create a new application.

2. In the Create Application dialog box, specify an Application Name (FtpAdapterAsServiceComponentApp).

3. Leave the Application Package Prefix field empty. In the Application Templates choose the SOA Application and click Next.

4. In the Project Name field enter a project name (FtpAdapterAsServiceComponentProj). In the Composite Template select Empty Composite and click Finish.

5. From the Component Palette select the FTP Adapter Service Adapter and drag it on the Exposed Services

6. On the Welcome to the Adapter Configuration Wizard, click Next.

7. On the Service Name screen, specify a service name (ReadFileService).

8. On the Adapter Interface, select the Define from operation and schema (specify later) radio button for the Interface option and click Next.

9. On the FTP Server Connection, specify the jndi connection name (I will create it later) as eis/Ftp/MyDemoFtpAdapter.

10. On the Operation screen, leave the File Type as Ascii, and select the Get File Operation Type option and click Next.

11. On the File Directories screen, specify a directory for the Incoming Files (/home/oracle/in). If you would like to archive the processed files, then specify an archive location (/home/oracle/archive) and click Next.

12. On the File Filtering screen, specify any name patterns that you would like to filter (*.xml) and click Next.

13. On the File Polling screen, specify the polling frequency (10 seconds) and the minimum file age (5 seconds) and click Next.

14. On the Messages screen, specify the schema of your files. For this tutorial, I am using an xml schema (note.xsd) and xml file (note.xml) from w3schools. So click the flash light next to the URL text box to browse to the note.xsd. Because I did not import the schema file in my project, click on the Import Schema File ... and browse to the note.xsd. Select the option Copy to Project and click OK.

15. On the Localize Files window just click OK.

16. Now on the Type Chooser, expand Project Schema Files, note.xsd and select the node element and click OK.

17. You should see now on the Messages screen the URL field is populated with the xsd/note.xsd value and the Schema Element set to note (this is our root element). Click Next and then Finish.

18. On the composite.xml you should see now the ReadFileService on the Exposed Services swim lane.

19. From the Component Palette drag a BPEL Process Service Component on the Components swim lane.

20. On the Create BPEL Process window, specify a name (BPELProcess1), a template (Synchronous BPEL Process). Deselect the option Expose as a SOAP Service and click OK.

21. From the Component Palette, drag a Mediator Service Component on the Components swim lane.

22. On the Mediator Component window, specify a name (Mediator1) and from the Template select Define Interface later and click OK.

23. From the composite.xml, drag a wire from the ReadFileService to the Mediator.

24. From the composite.xml, drag a wire from the Mediator to the BPELProcess1.

25. Double click the BPELProcess1 to open it with the BPEL editor.

26. Drag an Assign BPEL Activity between the receiveInput and replyOutput activities.

27. Create a Copy Operation assigning the input variable to the output variable and click OK.

28. From the composite.xml, double click the Mediator1 to open the Mediator1.mplan file.

29. Click on the Select an existing mapper file or create a new one option next to the Transform Using.

30. On the Request Transformation Map, select the Create New Mapper File and click OK.

31. From the mapper file (note_To_process.xsl), map one of the note elements (from) to the input element of BPELProcess1.

32. Click save and on the Save Warning click Save All

33. Before deploying the composite, you must create the Outbound Connection Pool for the ftp adapter that we have created. So go to your weblogic console (http://domain:port/console and login as weblogic.

34. Click Deployments from the domain structure and from the deploments table, select FtpAdapter.

35. Select the Configurations tab and in the Outbound Connection Pool Configuration Table click New.

36. On the Outbound Connection Groups, select javax.resource.cci.ConnectionFactory and click Next.

37. Specify a JNDI Name (for example, eis/Ftp/MyDemoFtpAdapter) and click Finish.

38. Click the Security tab (next to Configuration) and click New in the Credential Mappings table.

39. Select your Outbound Connection Pool (eis/Ftp/MyDemoFtpAdapter) and click Next.

40. On the WebLogic Server User screen, select the Configured User Name radion button and in the WebLogic Server User Name input field, enter your weblogic username (weblogic) and click Next.

41. On the EIS User Name and Password screen, enter your operating system user and password that you want to connect using FTP (please note that I am using Oracle Red Hat Linux 5 with vsftpd. I am not connecting using the root user but another user that i have created named oracle). Click Finish.

42. Deploy your project to your soa domain.

43. Place the note.xml in your input directory. The file adapter will pick it up, initiate the BPEL Process, copying the from element value to the BPEL’s input variable. The BPEL process will then copy the input variable to the output variable and reply back with the value.