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.

Thursday, February 4, 2010

File 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 (FileAdapterAsServiceComponentApp).

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 (FileAdapterAsServiceComponentProj). In the Composite Template select Empty Composite and click Finish.

5. From the Component Palette select the File 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 Operation screen, select the Read File Operation Type option and click Next.

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

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

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

13. 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.

14. On the Localize Files window just click OK.

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

16. 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.

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

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

19. 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.

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

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

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

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

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

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

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

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

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

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

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

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

32. Deploy your project to your soa domain.

33. 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.

Download: File Adapter as a Service Component