Monday, May 12, 2014

Rules on BlueMix

I saw lots of service provided by BlueMix platforms.Some of them are enterprise service can meet some business needs like rules,Elastic MQ service,CastIronLive,Single Sign-On (SSO) etc.Today I will introduce rule service on BlueMix.The Rules service provides managed execution of business rules for your applications.The service is based on the IBM Operational Decision Manager (IBM ODM) product, version 8.5.1.I  follow the sample and successfully deploy the application to the BlueMix.Below I will write some key steps when I deploy my rule application.

Below is the whole structure of rule service on the BlueMix.

1.When you apply for a rule service,it will provide the rule res server url to you.You will use that url to deploy your ruleApp.

2.Open the rule desginer and import the ,use RuleApp > Deploy. to deploy your ruleApp to previous server.

3.Enter the res console use step 1 provided link and login credential,you can see the ruleApp is deployed.There are two ways to invoke rule service in the BlueMix,one is used Rest API,another is useing HTDS.If you choose soap and click the view button you can get this ruleset wsdl .Otherwisde you can choose rest type and then click the view button to get rest url.

4.If you choose the saop type,you get can the wsdl link like
So you can use any web service client tool to invoke this webservice.Here we recommended to use Apach Axis2.
5.If you use rest type ,you need to download  WADL file.You can get the rest url from resources base file.

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="" xmlns:param="" xmlns:xsd="" xmlns:xsi="" xsi:schemaLocation=" wadl.xsd">
  <doc title="miniloan$45$rules"/>
    <include href="MiniloanAppMiniloanRulesParameters.xsd"/>
  <resources base="">
    <resource path="">
      <method name="POST">
        <doc title="execute"/>
The rest url  format will be :https://{host}:port}/DecisionService/rest/v1/{rulesetPath}?{options}
Also you can use the test button to test rule rest API.

6.In order to avoid hard coded these url,we can use java api to get rule service url.The below is part of code in the
public VCAPServiceParser() {

* Parses the VCAP_SERVICES
*            environment variable.
*            environment variable.
* */
private void parse(String vcapenv) {
if (vcapenv != null) {
ObjectMapper mapper = new ObjectMapper();
try {
JsonNode rootNode = mapper.readTree(vcapenv);
Iterator<String> fields = rootNode.getFieldNames();
while (fields.hasNext()) {
String element =;
if (element.startsWith(RULESSERVICE_PREFIX)) {
ArrayNode dsService = (ArrayNode) rootNode
// Get the First Rules Service Found in the
// VCAP_SERVICES env variable
JsonNode firstDsService = dsService.get(0);
JsonNode credentials = firstDsService

} catch (Exception e) {
LOG.severe("Unable to parse VCAP_SERVICES environment variable");

The application deployment procedure  you can reference below link.

When you launch the application,you need to change some values based on some conditions.

After you click the Submit Approval button,you can see the rule execution result.


  1. BlueHost is definitely the best web-hosting company for any hosting plans you might need.