Wednesday, October 29, 2008

How to Create A Multiple Entry Point BPEL Process Using Pick


In RIA development we want frequently want to consume web services. From a organizational point of view we typically want related methods to be provided by the same provider. If the web service is being provided via a BPEL process, how can we do that?

The answer is to use a BPEL process with a Pick activity.

Steps:

1) Create a normal synchronous BPEL process. Let the wizard create it's default input and output variables, as these won't be used.

2) Drop your custom input and output XSD files into the /bpel directory

3) Delete the the client partner link. When you do you'll be asked if you want to delete the Partner link -- answer Yes. You'll also be asked if you want to delete the WSDL file -- answer No to this.

4) Drop a Pick activity between the existing Receive and Reply activities. Now delete the Receive and Reply activities.

5) Edit the project WSDL file:
a) In the types section, delete the imports for the default XSD file, and add imports for your custom XSD files
b) Delete the existing messages and create a message for each request and response message you will be defining
c) Delete the existing portType definition. Add a new one, and under the portType add a new operation for each method you are implementing in this BPEL process via the Pick
d) Change the existing partnerLinkType to use your new portType

6) You will need to create an onMessage branch in the Pick for each operation being implemented:
a) Double click the message icon and select the partner link to associate with this message. On the first message you will need to create a new partner link.
b) Create the new input message variable, selecting the desired message type.
c) Select the appropriate operation type. This will bind the partner link message to this message branch.

7) You will need to add a sequence (or a scope/sequence combination) to each message branch and provide the rest of the activities within it.

8) If you are returning multiple return types (most likely), each branch will need a Reply activity at then end of it to return the output to the client.

Monday, October 27, 2008

Enable/Unlock OID User Account Using Java API

How to programmatically enable and/or unlock a user's OID account using the Java API? Let's take a step by step look:

First get a reference to the directory context:

ctx = oracle.ldap.util.jndi.ConnectionUtil.getDefaultDirCtx(ldapHost, ldapPort, ldapUserCN, ldapCred );

ldapUserCN will most likely be something like "cn=orcladmin" and ldapCred will be the password for that CN.

Next, we build an attribute set that we are going to update. This will do the account enable:

attrSet = new javax.naming.directory.BasicAttributes();
attrSet.put("orclIsEnabled", "ENABLED");
ctx.modifyAttributes(userDN, javax.naming.directory.DirContext.REPLACE_ATTRIBUTE, attrSet);

userDN here will be the full DN of the user we are modifying. We can also force a new password by putting the attribute "userpassword" in the attribute set and giving it the new password as its value.

Finally, we will do the unlock:

attrSet = new javax.naming.directory.BasicAttributes();
attrSet.put("orclpwdaccountunlock","1");
ctx.modifyAttributes(userDN, javax.naming.directory.DirContext.ADD_ATTRIBUTE, attrSet);

You should note that if you are modifying the user password programmatically, the password must adhere to all of the normal password rules set up for your OID instance.

The code can throw javax.naming.directory.InvalidAttributeValueException , which can be caused by a password not adhering to the OID policies.