Wednesday, February 21, 2007

Know-How by Ram Charan

I just finished reading Ram Charan's Know-How (The 8 Skills That Separate People Who Perform From Those Who Don't). I had previously read his books Execution and What the CEO Wants You To Know. He makes points illustrated with good examples from the many contacts he has with many top Fortune companies.

I will simply post his summary at the end of the book. I thought it was a very practical and focused book. Especially about setting goals and focussing on a few key priorities to achieve them.

The Eight Know-Hows

1. Positioning and Repositioning: Finding a central idea for business that meets customer demands and that makes money.
2. Pinpointing External Change: Detecting patterns in a complex world to put the business on the offensive.
3. Leading the Social System: Getting the right people together with the right behaviors and the right information to make better, faster decisions and achieve business results.
4. Judging People: Calibrating people based on their actions, decisions, and behaviors and matching them to the non-negotiables of the job.
5. Molding a Team: Getting highly competent, high-ego leaders to coordinate seamlessly.
6. Setting Goals: Determining the set of goals that balances what the business can become with what it can realistically achieve.
7. Setting Laser-Sharp Priorities: Defining the path and aligning resources, actions, and energy to accomplish the goals.
8. Dealing with Forces Beyond the Market: Anticipating and responding to societal pressures you don't control but that can affect your business.

Personal Traits That Can Help Or Interfere With the Know-Hows

Ambition - to accomplish something noteworthy BUT NOT win at all costs.
Drive and Tenacity - to search, persist, and follow through BUT NOT hold on too long.
Self-confidence - to overcome the fear of failure, fear of response, or the need to be liked and use power judiciously BUT NOT become arrogant and narcissistic.
Psychological Openness - to be receptive to new and different ideas AND NOT shut other people down.
Realism - to see what can actually be accomplished AND NOT gloss over problems or assume the worst.
Appetite for Learning - to continue to grow and improve the know-hows AND NOT repeat the same mistakes.

Saturday, February 17, 2007

Some good sample BPEL examples!

There are some good BPEL examples to work from at
http://www.activebpel.org/samples/samples-3/samples.php

Just a note beforehand, you should read the instructions for each example before trying to run them. I encountered some errors that were frustrating but after reading the instructions I was able to get them running.

I think it is a guy thing that instructions are for wussies. ;-)

The 2 examples that I ran so far

complex_exchange:
For the complex exchange, I had to set the following environment variables.

I set up the following environment variables
AESAMPLES_LIB=D:\Collin\University\COMP689\project\bpel\lib
CLASSPATH=.


1. Make sure that it the complex_exchange.bpr file gets deployed correctly
ant deploy-bpr
2. Then you should be able to run the client correctly
ant client



custom_functions:


This example has instructions where you have to
- edit the aeEngineConfig.xml as noted in the instructions
- copy the aecf-xmlstring.jar to the activeBpel engine's \shared\lib directory
- restart tomcat

1. Make sure that it the complex_exchange.bpr file gets deployed correctly
ant deploy-bpr
2. Then you should be able to run the client correctly
ant client



There is a deployment issue when you try to deploy both applications.
The error can be seen by looking at the deployment log:

http://localhost:8080/BpelAdmin/deployment_log_detail.jsp

Due to a Duplicate service name: complexToBpelPartnerLinkService in both bprs.

Wednesday, February 7, 2007

Implementing a Complex Axis Web Service

Well, I really want to do something more elaborate with ActiveBPEL and that will require the ability to write complex web services. I ordered the electronic version of "Developing Web Services with Apache Axis" by Ka lok 'Kent' Tong. I like it because it is real straightforward with working examples. There are also some chapters on Axis Security and Encryption which will definitely be worth reading when I get some time.

Check out http://www.agileskills2.org/DWSAA/index.html for more information.
The code is downloadable without cost.

I had to rework some of the code but I am glad to say that I got the complex web service up and running in the ActiveBPEL environment.

You can download my project for this. It is not in a super tidy state but should get you going.
Download it from Here
There are 2 ant files that I use:

buildTheStubs.xml - This will build the stub java source files for the complex web service

buildAndDeployWS.xml - This will deploy the compile and deploy the web service to ActiveBPEL

I copied them into build.xml when I want to run them each.

There is a client java class StubClient.java which will be able to talk to the deployed webservice.

The web service implementation BizServiceSOAPImpl.java
exposes a method
public ProductQueryResultResultItem[] query(ProductQueryQueryItem[] queryRequest) throws java.rmi.RemoteException, InvalidQuery {
}

which is quite obviously complex in that it does not have any simple types as parameters or return types.


The client works fine except when I try to look at the wsdl for the webservice
http://localhost:8080/active-bpel/services/BizServiceSOAP?WSDL on my machine

I get the following error message that I will try and have a look into:

AXIS error

Sorry, something seems to have gone wrong... here are the details:Fault - makeTypeElement() was told to create a type "{http://foo.com}>>productQuery>queryItem", with no containing element

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: makeTypeElement() was told to create a type "{http://foo.com}>>productQuery>queryItem", with no containing element
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:kepi

Thursday, February 1, 2007

Writing a simple Axis Web Service

If I am going to be doing any real BPEL development. I really have to be able to make my own web services. I basically stripped out the BPEL and JSP components of the loan approval example.

I created a simple java class that will be exposed as a web service:

Web Service:

package com.smith.ws;
import java.util.Date;

public class SimpleWebService {

public String simpleCall(String someString)
throws SimpleWebServiceProcessFault
{
String response = null;
try
{
System.out.println("Calling "+this.getClass());
//do some business logic
Date now = new Date();
response = "*"+someString+"*"+now;
}
catch (Exception e)
{
throw new SimpleWebServiceProcessFault("simpleCall", e.toString(),"99");
}
return response;
}
}


You then have to update the service.wsdd file to expose it as a web service:

Service.wsdd

Something like:

< name="SimpleWebService" provider="java:RPC">

< name="className" value="com.smith.ws.SimpleWebService">
< name="allowedMethods" value="*">

<>


The ant build creates a simplewebservices.wsr and copies it to the /bpr directory

Calling the web service:

Service service = new Service();
Call call = (Call)service.createCall();
String urlString = "http://localhost:8080/active-bpel/services/SimpleWebService";
call.setTargetEndpointAddress(new java.net.URL(urlString));
call.setOperationName("simpleCall");
call.addParameter("someString", org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);

String result = null;
try
{
result = (String)call.invoke(new Object[] {"My Call"});
}
catch (AxisFault af) {
if (SimpleWebServiceProcessFault.hasMagicFaultErrorCode(af))
result = "99";
else
result = af.toString();
}
catch (Exception e) {
result = "unexpected exception seen: " + e.toString();
}

System.out.println("Client result = " + result);


Basically taking the input argument and returning it dressed up with some asterisks and the current time.

Sample run:
Client result = *My Call*Thu Feb 01 20:13:33 MST 2007


You can download the sample simple web service bundle here:
1simplews.zip

Monday, January 29, 2007

Dynamic Dropdown List using AJAX

I wanted to discover how to use AJAX to populate a dynamic dropdown list based on the input of some controls on the current page.

There are 2 dropdown lists which determine the elements of the third dropdown list.

Please see the live demonstration Here

The sample code (jsp and php) can be downloaded at Sample Code

Basically on the onchange event of the first 2 dropdowns, there will be an ajax call to retrieve values for the third dropdown.

There are 3 files:

1. dropdownPage.jsp(php) - main page which makes backend calls to retrieve the 3rd dropdown values
2. dataPage.jsp(php) - which provides the server data(nested xml) for the third dropdown
3. dropdownResults.jsp(php) - which simply shows which values the user has selected



The heart of the code is in the javascript processing on the dropdownPage.jsp:

AJAX Scripting (JSP Version):

function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = populateDropDown;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function ()
{ if (xmlDoc.readyState == 4)
populateDropDown()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}

//determine url to get xml
var dd1Param = document.f1.dd1.value;
var dd2Param = document.f1.dd2.value;
var url = 'dataPage.jsp?dd1='+dd1Param+'&dd2='+dd2Param;
//load the xml
xmlDoc.load(url);
}


function populateDropDown()
{

var browser = 'ie';
var nameIndex = 0;
var valueIndex = 1;
if (document.implementation && document.implementation.createDocument)
{
browser = 'firefox';
var nameIndex = 1;
var valueIndex = 3;
}

var dd3 = document.f1.dd3;

//empty control
for (var q=dd3.options.length;q>=0;q--)
{
dd3.options[q]=null;
}

var x = xmlDoc.getElementsByTagName('item');
for (j=0;j < x[0].childNodes.length;j++)
{
if (x[0].childNodes[j].nodeType != 1) continue;
var theData = document.createTextNode(x[0].childNodes[j].nodeName);
}

for (i=0;i < x.length;i++)
{
var name = '';
var value = '';
for (j=0;j < x[i].childNodes.length;j++)
{
if (x[i].childNodes[j].nodeType != 1) continue;
var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
if (j==nameIndex) name = theData.nodeValue;
if (j==valueIndex) value = theData.nodeValue;
}

dd3.options[i] = new Option(name, value);
}
}

function submitform()
{
var dd1 = document.f1.dd1;
var dd2 = document.f1.dd2;
var dd3 = document.f1.dd3;
var dd1Value = dd1.options[dd1.selectedIndex].value;
var dd2Value = dd2.options[dd2.selectedIndex].value;
var dd3Value = dd3.options[dd3.selectedIndex].value;

var page = "dropdownResults.jsp?dd1="+dd1Value+"&dd2="+dd2Value+"&dd3="+dd3Value;
window.location = page;
}

One thing I do like about this example is that the data read provides a nested xml structure as follows:

Monday, January 22, 2007

Understanding ActiveBPEL Tutorial Test Client



Going through the BPEL construction process worked well but I also wanted to discover how the rest of the tutorial worked. So I dug in and hopefully this breakdown will help you. It helped me! :-)





The loan approval components A-F:

A. index.jsp:

Form with values such:
FirstName: John
LastName: Smith
Amount: 500
Operation:request
URL: http://localhost:8080/active-bpel/services/LoanService
Assessor Response: high,low,FAULT
Approver Response: yes,no, FAULT

Upon Submission:

- A form that submits to itself in which the jsp will make a call to the BPEL process

Step 1: update the values of "loan_approval_config.xml"
(~\Active Endpoints\ActiveBPEL Designer\Server\ActiveBPEL_Tomcat\temp\loan_approval_config.xml)
is updated with the values from the form via the RuntimeParams.java class using xpath notation.

Step 2:
Get the BPEL result via the following call:

This call grabs the newly updated values form the above loan_approval_config.xml
and essentially makes a call to the web service via code like:

BPELTestClient.java

Service service = new Service();
Call call = (Call)service.createCall();
String urlString = rp.getAttr("/rundata/client", "url");
call.setTargetEndpointAddress(new java.net.URL(urlString));
call.setOperationName(rp.getAttr("/rundata/client", "operation"));
call.addParameter("firstName", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("name", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("amount", org.apache.axis.Constants.XSD_INTEGER,
ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);

firstName = rp.getText("/rundata/client/firstName");
lastName = rp.getText("/rundata/client/name");
amount = new BigInteger(rp.getText("/rundata/client/amount"));
result = (String)call.invoke(new Object[] {firstName, lastName, amount});

Note however that the index.jsp updates the values for the Assessor and Approver web services in the loan_approval_config.xml.




B. RuntimeParams.java

Class designed to update the "loan_approval_config.xml" file.
It contains a org.w3c.dom.Document and a java.io.File instance variable so that the xml document can be updated via xpath notation.


C. Constants.java

public interface Constants {
public static final String MAGIC_FAULT_STRING = "FAULT";
public static final String MAGIC_FAULT_ERROR_CODE_STRING = "42";
public static final String UNEXPECTED_ERROR_CODE_STRING = "9999";
}



D. loanProcessFault.java

Special extension of org.apache.axis.AxisFault which is thrown by the 2 Web Services
ApproverWebService.java and the AssessorWebService.java


E. The Web Services

Looking at the 2 web services used in the BPEL:

1. ApproverWebService.java
Simply retrieve a value from the loan_approval_config.xml file
RuntimeParams rp = new RuntimeParams();
response = rp.getText("/rundata/approver/accept");

2. AssessorWebService.java
response = rp.getText("/rundata/assessor/risk-level");


Summary
So basics of this BPEL client is index.jsp which

1. updates a loan_approval_config.xml with form values
2. makes a call the to the BPEL by reading the values from loan_approval_config.xml
3. the two partnerLink webservices(Approver and Assessor) read their values from this xml file
4. the jsp is returned the results from the BPEL call

Sunday, January 21, 2007

ActiveBPEL Designer

I received a license key for the ActiveBPEL Designer(3.0.1) tool and installed the Designer. To get the key you have to submit some personal information and they send you a link to the license key, some case studies, and links to the support groups. The installation went smoothly and no complaints.

You can get it Here

There is a "loan approval" tutorial where you build the BPEL workflow from the ground up using the ActiveBPEL Designer interface. I have done some tutorials where code does not work but this one was without a hitch.

The ActiveBPEL Designer is built on top of Eclipse and also comes with a Tomcat server within. So you will have to change your CATALINA_HOME environment variable.


From techinitiatives


Active BPEL Tutorial(Loan Approval)

Part 1: Starting a New Process
Part 2: Planning and Designing a Process
Part 3: Adding Web References
Part 4: Using the Operation Activities and Properties
Part 5: Adding Process Activities and Properties
Part 6: Adding Fault Handling
Part 7: Adding Compensation and Correlation(This is actually an empty step)
Part 8: Simulating the Process
Part 9: Deploying the Process
Part 10 Running the Process on the Server
Part 11: Debugging Your Process on the Server

I am pretty new to "Web Services" and SOA. This tutorial did not have any incorrect information or missing steps. This is something that I appreciated greatly.

I made a BPEL process from the ground up(minus the partner web services and client jsp however). But this is a good step into BPEL. I liked the GUI alot and was impressed with the simulating and debugging features. Just getting started but I like what I see so far!