Monday, February 4, 2008

Using Oracle BPEL PM with a Proxy Server

It's the BPEL blues again. It must just be me. It seems every time I try to do something new with the Oracle BPEL Process Manager I have a problem. I read the documentation (that I can find), follow to the letter (or so I think), and try variations, often involving multiple restarts. All this chews up time, sometimes hours sometimes days. This time it involves a project whereby I have to get some data from a new application we've had developed using Siebel CRM OnDemand, and pass it to an internal reporting system. For those of you new to Siebel CRM OnDemand, it's a bit like Salesforce.com in that you can roll your own CRM system using their web-based development framework. A nifty idea that I think we will see more of in other application areas in the years ahead.

So our Oracle BPEL PM sits on our internal network and needs to talk to OnDemand which is located outside on the Internet. Of course everything that does this from our network has to do so via the proxy server(s). Sounds easy right? We are using Oracle BPEL PM 10.1.3.3 and according to the nearest documentation I could find (OAS Installation Guide 10.1.3.1) :-

7.7 Proxy Settings
If you want the Oracle Application Server instance to use a proxy server, perform the
following steps:
1. Run the following command to shutdown all processes:
C:\> ORACLE_HOME\opmn\bin\opmnctl shutdown
2. To set the proxy server for BPEL, modify the following lines in the ORACLE_
HOME\bpel\bin\obsetenv.bat file:
set PROXY_SET="true"
...
:set_proxy
set OB_JAVA_PROPERTIES="-Dhttp.proxySet=true" "-Dhttp.proxyHost=proxy_server_
hostname" "-Dhttp.proxyPort=proxy_server_port"
"-Dhttp.nonProxyHosts=localhost|non_proxy_host|other_non_proxy_hosts"
:end_set_proxy
3. To set the proxy server for OC4J, modify the following lines for the OC4J module
in the ORACLE_HOME\opmn\config\opmn.xml file:






-Dhttp.proxySet=true -Dhttp.proxyHost=proxy_server_hostname
-Dhttp.proxyPort=proxy_server_port
-Dhttp.nonProxyHosts=localhost|non_proxy_host|other_non_proxy_hosts"/>




So that's it right? Being a Windows user, (sorry all you fans of the 20+year-old-Linux-command-line UI paradigm) I'm used to starting everything from the Start menu, and besides, the Oracle BPEL PM Developers Guide clearly states that to start the BPEL PM in a Windows environment you should "Select Start > All Programs > Oracle -
Oracle_Home > Start SOA suite" (Developer’s Guide 10.1.3.1.0 B28981-03 section 2, table 2-1). Silly me for following this documentation. To get the BPEL PM to actually pick up your changes to the config files in regards to proxy settings, you must ignore this documentation and instead follow the OAS Installation Guide that states to start a middle tier instance you should use the following command line "(Windows) ORACLE_HOME\opmn\bin\opmnctl startall". From my tests - you only have to do this once to pick up the config changes. After that you can continue to start it from the Start menu and it will continue to use the config changes you made earlier.

You can see the settings the server is actually using in a couple of ways.

1. Go into the OAS Enterprise Manager and navigate to Cluster Topology > Application Server: home.yourserver > OC4J: home.yourserver soademo (or your soa home) > Server Properties. At the bottom of the page click Server Properties. Browse through the pages and you will find the http.proxySet parameter (and others if they exist), that are being used by the server.

2. Inside a test BPEL process use Embedded Java to read the system properties and write them to the domain.log so you can view the values after the process has been run. To do this, add an embedded java component and fill it in as follows:-

String vProxySet = System.getProperty("http.proxySet");
String vProxyHost = System.getProperty("http.proxyHost");
// more vars here if you want them...
Logger logger = Logger.getLogger("default.collaxa.cube.engine.deployment");
logger.info("Test environment Var http.proxySet : " + vProxySet);
logger.info("Test environment Var http.proxyHost : " + vProxyHost);
// more log writes here if you want them...

To get this to work you must import the appropriate Java library into the BPEL process. To do this, add the following line in the BPEL source view just before the embedded java component :-



This adds the log4j library, which is what Oracle BPEL PM normally uses for its logging. After deploying and running your test BPEL process, search for and open the domain.log file and you will see your custom log entries near the bottom.