Technical Documents
Knowledge Driven Web Services
Today, businesses are using Web services and service-oriented architecture (Web services/SOA) to reduce integration costs and make developing systems to be more efficient and effective. The following article discusses how to deploy HaleyRules in a Web Service environment, and also gives some insight into Haley's own HaleyRules-Web Service.
Organizations utilizing web services are able to externalize business rules and increase accessibility across applications used by various departments. Organizations leveraging and enforcing a common set of rules result in the break down of organizational silos. The ultimate result is that organizations' utilizing web services are able to easily adjust to the dynamic regulations, business practices, and auditing processes.
HaleyRules-WS makes use of the Haley rules engine, either HaleyRules-JP (Java Platform) or HaleyRules-SP (Specific Platform). Users are also still able to leverage the power of HaleyAuthority, and additional Haley authoring tools to create and maintain the knowledge base that implements the logic for the Web service. HaleyRules-Webservice was built to utilize either HTTP(S) or JMS as a transport. If using HTTP or HTTPS as a transport mechanism, you need a Web server that supports the servlet API, such as Tomcat. If using JMS as a transport, a JMS implementation that implements JMS 1.0 or later. JMS providers include OpenJMS and Websphere MQ. The following diagrams show a general HaleyRules-WS architecture, using both JMS and HTTP(S) as transport mechanisms:
Figure 1: HaleyRules-WS using JMS transport

Figure 2: HaleyRules-WS using HTTP transport

Configuring HaleyRules-WS for JMS
There are many possible configurations for the communication between your application client, the JMS provider, and the HaleyRules-WS server. Popular configurations include:
Input/output queue
HaleyRules-WS can be set-up to operate with separate request (input) and response (output) queues.
Figure 3: Web service with JMS transport and input/output queue

Single queue with message selector
In this configuration, request and response messages share a single queue. HaleyRules-WS is configured with a filter to select only request messages from the queue. Response messages are identified by headers appended by the knowledge base invocation.
Figure 4: HaleyRules-WS with JMS Transport and single message queue.

Configuring HaleyRules-WS for HTTP
Properties and behavior of HaleyRules-WS using the HTTP transport are defined in the standard J2EE web.xml deployment descriptor file, which is read in upon invocation of HaleyRules-WS
Using HaleyAuthority with HaleyRules-WS
When using HaleyRules-WS, an application communicates with the Web Service via XML messages that conform to one or more XML Schemas (XSDs). HaleyAuthority needs to be aware of all the XSDs that define the structure of the XML messages that the rules engine will receive and generate as responses. Optionally, you may also configure the rules engine to add transport-specific messages to its responses. When using SOAP over HTTP, the operation to be performed on the data is typically provided as the value of the soapaction header in the HTTP request. Module applicability conditions can test for different values to invoke different sets of rules. E.g., if a request is for the validation of a purchase order.
XML Schema used by HaleyRules-WS
There are several standard XML schemas are used to specify the content and structure of the XML documents used to communicate with the HaleyRules-WS server. HaleyRules-WS uses the W3C Schema language (.xsd files) to specify XML content and structure. The schemas you need will depend on the transport protocol that you choose (JMS or HTTP). Standard schemas are included to define the SOAP envelope and message payload, message format for JMS-based communication and JMS properties, message format for HTTP-based communication, HTTP properties and header information, as well as the SOAP envelope and message payload.
Fault-tolerance
The deployment options available with HaleyRules-WebService allow you to take full advantage of the fault-tolerance of your messaging architecture. For JMS, these include running more than one JMS Web server that services the same queue. For HTTP(S), replicate the application server, using a load-balancing switch.
To find out more about how HaleyRules-WebService can be used to help your organization, give one of our solutions experts a call @ 724-934-7853.
