Wednesday, December 9, 2009

Leveraging Spring in SOA Suite 11g

I've written the following how-to based on the excellent Viewlet from my colleague Clemens Utschig.
http://docs.google.com/Doc?docid=0AbYrnfO7h717ZGZuMmhqOTRfMWhkNmI0NGQ0&hl=en


The viewlet is available at -
http://www.oracle.com/technology/products/soa/soasuite/demos/scalight/springcomponentbasedemo.html

Thursday, November 26, 2009

BAM 11g Buttons disabled?

You log in to BAM 11g
http://localhost:9001/OracleBAM

as weblogic/welcome1 for example and the buttons - are disabled?

Then go to em
http://localhost:7001/em

Right-mouse click on soa-infra
Select Security --> Application Roles
Search for all roles
Check that "Administrators" is a member of the BAM Roles.


Login to BAM again

Wednesday, November 18, 2009

JDev 11g - ADF Mobile on my Blackberry

Pre-requisites
· Access to the SCOTT schema on an Oracle DB

· Blackberry Email/MDS server simulator > BlackBerry_Email_MDS_4.1.4.exe

· Blackberry simulator E.g.
> BlackBerry_Simulators_4.6.1.168_8900-Vodafone.exe
· Both downloadable from http://na.blackberry.com/eng/developers/browserdev/devtoolsdownloads.jsp


Install / Start Blackberry Software
· Install both simulators

· Start MDS emulator
--> Start Programs --> Research in Motion --> Blackberry Email and MDS Services Simulators 4.1.4 --> MDS

This will open a cmd window.

· Start Blackberry 8900 emulator
--> Start --> Programs --> Research in Motion --> Blackberry Smartphone Simulators 4.6.1. --> 4.6.1.168 --> 8900-Vodaphone

This will start up the Simulator.


Create the ADF Mobile App

· Create a new application in JDev 11g --> Fusion Web Application (ADF)
. Enter app name --> Accept defaults on all other screens
Create the data model
--> Right-mouse click on the Model project -->
--> New... ADF Business Components --> ...from Tables


· Create a new DB Connection


· Select Entity Objects


· Select View Objects


· Specify Application Module


Create the UI

· Double-click on faces-config.xml in the ViewContrioller project
--> Drop a JSF page onto the designer


Double-click to create the page
--> Select Render in Mobile Device



Drop EmpView as a Tables --> Trinidad Read only table




Run mobile.jspx



Looks good in IE, but let’s change the project setting so as to avoid having to type such a long URL in the Blackberry.

--> Right-click on ViewController project
----> Project properties --> Java EE Application Change context root to xyz
Re-test in IE

Test in Blackberry

Open browser


Type in the URL
I have installed the MSFT loopback adapter on my machine (ip address = 1.1.1.1) so that is what I use here. e.g. http://1.1.1.1:7101/xyz/faces/mobile.jspx


You can enable JavaScript and create a couple of more interesting pages





Tuesday, November 17, 2009

ADF 11g - Hierarchy Viewer Example with BFile

In this lab I will leverage the ADF Hierarchy Viewer to display data on Countries and Regions in an innovative way.

Pre-Requisites

- 2 DB Tables --> Country, Region

CREATE TABLE COUNTRY
(
COUNTRY VARCHAR2(20 BYTE) NOT NULL,
POPULATION NUMBER(10, 0) NOT NULL,
CAPITAL VARCHAR2(100 BYTE) NOT NULL,
GNP VARCHAR2(20 BYTE) NOT NULL,
BURGER_INDEX NUMBER(3, 2) NOT NULL,
IMAGE BFILE,
COMMENTS VARCHAR2(100 BYTE)
, CONSTRAINT COUNTRY_PK PRIMARY KEY
(
COUNTRY
)
ENABLE
)
TABLESPACE "USERS"
LOGGING
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE
(
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
;

CREATE TABLE REGION
(
REGION VARCHAR2(100 BYTE) NOT NULL,
COUNTRY VARCHAR2(20 BYTE) NOT NULL,
CAPITAL VARCHAR2(100 BYTE) NOT NULL,
IMAGE BFILE,
MOST_SCENIC_SITE VARCHAR2(100 BYTE),
COMMENTS VARCHAR2(255 BYTE)
, CONSTRAINT REGION_PK PRIMARY KEY
(
REGION
)
ENABLE
)
TABLESPACE "USERS"
LOGGING
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE
(
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
;

ALTER TABLE REGION
ADD CONSTRAINT REGION_COUNTRY_FK FOREIGN KEY
(
COUNTRY
)
REFERENCES COUNTRY
(
COUNTRY
)
ON DELETE CASCADE ENABLE
;

Add Some Test Data, I'm using jpgs for Ireland and its 4 regions

– In SQLPLUS -->


Create or replace directory imagedir
AS 'D:\fmw11g\demos\ADF-General\images';
insert into country values (’Ireland’, 4000000, ’Dublin’, 200, 4.5,
bfilename ('IMAGEDIR', 'Ireland.JPG'), ’ Great Place to Live! ’);

insert into region values (’Leinster’, ’Ireland’, ’Dublin’,
bfilename ('IMAGEDIR', 'Leinster.JPG'), ’ Hill of Howth ’,
’ Well worth a visit! ’);

insert into region values (’Ulster’, ’Ireland’, ’Belfast’,
bfilename ('IMAGEDIR', 'Ulster.JPG'), ’ Giants Causeway’,
’ Well worth a visit! ’);

insert into region values (’Munster’, ’Ireland’, ’Cork’,
bfilename ('IMAGEDIR', 'Munster.JPG'), ’ Ring of Kerry ’,
’ Well worth a visit! ’);

insert into region values (’Connaught’, ’Ireland’, ’Galway’,
bfilename ('IMAGEDIR', 'Connaught.JPG'), ’ Connemara’,
’ Well worth a visit! ’);

Check in JDev DB Browser


Create the ADF App

1. Create an ADF app of type – Fusion Web Application (ADF)


1.1. Accept defaults on the next screens.
2. Right-mouse click on the Model project
2.1. New...


2.1.1. Create a new DB connection for scott




2.1.2. Select Entity Objects

2.1.3. Select View Objects


2.1.4. Specify Application Module




3 Add a Servlet to retrieve the BFile Images


3.1. Right-mouse click on the ViewController project and select New...




3.2. add the Servlet code –


package view.servlet;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.BFileDomain;
import oracle.jbo.domain.BlobDomain;

public class GetImagesServlet extends HttpServlet { private static final String CONTENT_TYPE = "image/jpeg; charset=windows-1252";

public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);

/* here we will pass in the country / region as key for image retrieval */
String country = request.getParameter("Country");
String region = request.getParameter("Region");
String where = "";

OutputStream os = response.getOutputStream();

// get a handle to the Application Module
String amDef = "am.AppModule";
String config = "AppModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
ViewObject vo = am.findViewObject("CountryView1");
BFileDomain image = new BFileDomain();

// set where clause for country or region and get approp. View
if (country != null){
where = "country = " + "'"+ country +"'";
vo.setWhereClause(where);
vo.executeQuery();
}

if (region != null){
where = "region = " + "'"+ region +"'";
vo = am.findViewObject("RegionView1");
vo.setWhereClause(where);
vo.executeQuery();
}
if(vo.getEstimatedRowCount() != 0){
Row row = vo.first();
image = (BFileDomain)row.getAttribute("Image");
image.openFile();
InputStream is = image.getInputStream();
// copy bfile to output
byte[] buffer = new byte[10 * 1024];
int nread;
while ((nread = is.read(buffer)) != -1)
os.write(buffer, 0, nread);
os.close();

}

vo.setWhereClause(null);
Configuration.releaseRootApplicationModule(am, false);
}
}

4. Create a jsp to display the Country hierarchy
4.1 Double click on faces-config.xml

4.2 Drop a JSF page icon onto the designer --> Rename to hierarchy.jspx



4.3 Double click on hierarchy.jspx to create the page

4.4. Open the Data Controls


4.5 Drop CountryView1 as Hierarchy Viewer...

Radial















4.6. Set the image source to point to the servlet





























Friday, November 6, 2009

Calling Java Classes from SOA Suite 11g

Essentially the same procedure, from a development perspective, as in 10g -
but under the hood we're using the 11g Infrastructure layer.

The Oracle documentation can be found at
http://download.oracle.com/docs/cd/E12839_01/integration.1111/e10224/bp_java.htm#BABCBEJJ


Here's a simple example based on WSDL Java binding, later posts will cover bpel:exec etc. -

1. Create a generic Application/Project in Jdev 11g

1.1. Add 2 classes - Cust & Greeting

Cust -

package cccwsif;

public class Cust {

private String custName1;
private String custName2;
private String custXMASgreeting;


public Cust() {
super();
}

public void setCustName1(String custName1) {
this.custName1 = custName1;
}

public String getCustName1() {
return custName1;
}

public void setCustName2(String custName2) {
this.custName2 = custName2;
}

public String getCustName2() {
return custName2;
}

public void setCustXMASgreeting(String custXMASgreeting) {
this.custXMASgreeting = custXMASgreeting;
}

public String getCustXMASgreeting() {
return custXMASgreeting;
}
}

Greeting -

package cccwsif;

public class Greeting {
public Greeting() {
super();
}

public Cust XMASgreet(Cust c){
String g = "Happy Christmas " + c.getCustName1() + " " +
c.getCustName2();
c.setCustXMASgreeting(g);
return c;
}
}

1.2. expose Greeting as a Web Service
1.2.1. Right-mouse click on Greeting
1.2.2. Then select "Create Web Service..."






1.2.3. Accept defaults for all steps up until step 9.
1.2.4. Additional Classes --> Include "Cust" class




1.2.5. open the wsdl file and set nillable=false




1.2.6. open the GreetingService-java-wsdl-mapping.xml file
1.2.7. check the mapping order

1.3. Add the Java Binding to the WSDL
1.3.1. Open the wsdl in "Design" mode
1.3.2. Click the + by Bindings



1.3.3. Click the Map button
1.3.4. select the Cust class


1.3.5. Amend the Service entry in the WSDL as follows -

1.4. Jar up the project
1.4.1. File --> New --> Deployment Profile --> Jar
1.4.2. Deploy to Jar




2. Create a SOA App in JDev 11g

2.1. Copy the WSDL into the project


2.2. Drop a BPEL service component onto the designer
2.2.1. Set input / output as follows -



2.3. Add a partner Link to the process, pointing to the imported WSDL
2.3.1. Add Assign - Invoke - Assign Activities




2.3.2 Assign input / output vars in the 2 Assigns
2.4. Copy the Jar file from the previous project to the SOA Project sca-inf\lib directory




2.5. Deploy the SOA App

3 Test






































Friday, October 23, 2009

Oracle ADF 2 SOA via Event Delivery Network

EDN takes the pain out of messaging - providing more business / IT alignment. For more info please see
http://blogs.oracle.com/soabpm/2009/07/event_delivery_network_chapter.html


In this simple lab I will detail how to raise a business event in an ADF app (in this case, it is the creation of a new order) and consume the event in a SOA app. Pub/Sub at a higher level.


0. Create the ORDERS DB table

0.1. run the following in SQLPLUS

drop table orders;

Create table orders(
order_nr varchar2(20) not null,
customer varchar2(50) not null,

email varchar2(50) not null,
country varchar2(50) not null,
phone varchar2(50) not null,
product varchar2(50) not null,
quantity number(10) not null,
unitPrice number(10,2),
supplier varchar2(50) ,
totalPrice number(10,2),
orderStatus varchar2(50) ,
comments varchar2(256)
);

ALTER TABLE orders ADD PRIMARY KEY (order_nr);


1. Create the ADF App

1.1. Create a new application of type Fusion Web app in JDeveloper
1.2. In the Model project - Create a new ADF BC for the ORDERS table
1.3. Open the Entity Object definition



1.4. Add an Event Definition
1.4.1. Select all of the Entity Object attributes


1.4.2. Define Event Publication
Here we publish an event whenever a new order is created.


2. Create the UI

2.1. Create 2 pages
2.1.1. browseOrders.jspx
2.1.2. createOrder.jspx
2.2. Create 2 navigation cases
2.2.1. create – from browseOrders to createOrder
2.2.2. return – from createOrder to browseOrders



2.3. browseOrders.jspx

2.3.1. Drop the orders DataControl onto the page as an ADF Read Only Table
2.3.2. Drop the CreateInsert operation as an ADF button



2.3.3. Rename button to Create Order.

2.3.4. Set button action attribute to create



2.4. createOrder.jspx

2.4.1. Drop the orders DataControl onto the page as an ADF Form
2.4.1.1. Include Submit button
2.4.2. Drop the Commit & Rollback operations as ADF buttons
2.4.2.1. Set the disabled attribute for both buttons to false.


3. Create a SOA App to consume the event

3.1. Create a new SOA Application



3.2. Copy the EDL and XSD schema files from the ADF app to the SOA project's root directory. For example:
D:\jdevinstance\mywork\SOA-ADF-EDN\SOA-ADF-EDN

e.g.

From



To



3.3. Create a Mediator in the SOA app to subscribe to the event



3.4. Create an outbound File Adapter, we will simply write the new order to a file.
3.4.1. Firstly create the output directory e.g. out



3.5. Create the FileAdapter







3.6. Wire to Mediator

3.7. Create the data mapper for Mediator--> FileAdapter



4. Deploy the 2 apps

4.1. Deploy the composite to soa_server1
4.2. Deploy the ADF app to soa_server1
4.2.1. Before deploying, set the BC configuration to use J2EE Datasources





4.3. Define a new datasource ,jdbc/scottDS, in the WLS Console




4.3.1. Test the Connection

4.3.2. Target Datasource to soa_server1



5. Test the App

e.g.
http://localhost:8001/ADF-EDN-ViewController-context-root/faces/createOrder.jspx

If you have issues with the URL, then check your app context root in JDeveloper
Right click on the ViewController project --> Project Properties

5.1. Click Create Order




5.2. Click Submit and then Commit.



5.3. Check for a new instance of SOA-ADF-EDN in the SOA Console



5.4. Check the output directory