Connecting to the Rules Service via HTTP

Previous Next

See Also

You can access the Rules Service via the HTTP protocol. The syntax of an HTTP command calling the Rules Service is:

http://<host>:<port>/<application>/<user>/<ResponseType>/

<command>?$Password=<password>&CommandVariable

where:

· <host> is the name of the server where the Rules Service is running.

 

· <port> is the port number that the Rules Service uses to communicate with client applications.

 

· <application> is the name of the USoft application.

 

· <user> is the name of the USoft application user.

 

· <ResponseType> specifies what type of response is expected as a result of the command. Allowed values are:
· html

 

· xml

 

· xml-SOAP

 

· plain

 

· <mime-type> (See example 4, below)

 

· when using formal types like text/html, the '/' character must be encoded so that it is interpreted correctly, for example:

   text%2Fhtml.

· <command> is the actual command. Allowed values are:
· query

Sends the SQL SELECT statement defined in the $SQL variable to the Rules Service. Results in an HTML formatted table.

· SqlScript

Start the SQL statement defined in the $SQL variable. This way, you can call a decision or a batch job, for example.

· <component name>.<method name>

Invokes a method of an RDMI component. This component can be defined, or can be an internal component like the XML component.

· If you use a method from a component, and you need to provide parameters for this method call, you can add them in the query part of the URL, for example:

http://<host>:<port>/<application>/<user>/<ResponseType>/<Component Name>.<Method Name>?$Password=<password>& arg1=Hello World

· Single quotes can only be used, and must be used, as escape character inside a SQL statement. See example 2 below.

 

· If an argument is too large to pass via the URL (Internet Explorer has a maximum length of 2083 characters), you can use the content of the HTTP POST request, for which there is no limit. To do this, you must use the :$Content place holder in the URL. This is useful, for example, when XML documents are used. See example 5, below.

Example 1

This HTTP call invokes the internal XML component, and executes a query in XML format:

http://localhost:7777/TRAVEL/TRAVELUSER/xml/xml.query?$Password=TrustMe&XmlDocument=<Query><Table Name="PERSON"></Table></Query>

Example 2

This HTTP call starts a SQL statement inserting a record in the TOUR table, and then issues a commit:

http://travelserver:4711/TRAVEL/TRAVELUSER/plain/SqlScript?$Password=TrustMe&$SQL=insert into TOUR values('MEXICO','DIVING',4,60);commit

Example 3

This HTTP call starts the BenchMark Profiler by invoking the internal RulesEngine component:

http://localhost:7777/TRAVEL/TRAVELUSER/plain/RulesEngine.RuleProfilerStart?$Password=TrustMe

The resulting text is: "Profiler activated". You can stop the Profiler with HTTP call:

http://localhost:7777/TRAVEL/TRAVELUSER/plain/RulesEngine.RuleProfilerStop?$Password=TrustMe

with resulting text: "Rule profiler stopped successfully".

NOTE:

Only the Rules Engine through which the RuleProfilerStart command was issued will be profiled. You should ensure that this is the only Rules Engine under the RulesService that is running for the application that you wish to profile. Also make sure that you are the only user of the Rules Service during this test.

For more information, refer to BenchMark help topic: "How to Make a Profile using the Stand-alone Profiler from Within Another Application".

Example 4

This HTTP call retrieves an SVG Image from a CLOB field: the image must be recognized by the browser as SVG. To do this, use mime-type "image/svg+xml":

http://localhost:7777/TRAVEL/TRAVELUSER /image%2Fsvg%2Bxml/SqlScript?$Password=TrustMe&$SQL=select%20DOCUMENT%20from%20SVGDOCUMENT%20where%20PK=2

Example 5

This example shows how to use the :$Content place holder It uses an ASP page calling a RulesService so that it can insert a record ('A', 'B') in the table TAB. This example uses the XMLHTTP object of the Microsoft XML Parser.:

<OBJECT RUNAT=server PROGID=MSXML2.XMLHTTP id=xmlhttp></OBJECT>

<%

     myxml = "<X><TAB COL1=""A"" COL2=""B""><Insert/></TAB></X>"

myscript = "invoke xml.import with select :'$Content' XMLDocument; commit"

urlrequest = "http://<server name>:<port nr>/<Application Name>/<UserName>/html/SqlScript?$Password=<Pwd>&$SQL=" & myscript

     xmlhttp.open "POST", urlrequest, False

     xmlhttp.send myxml

     response.ContentType = "text/xml"

     response.Write "<Result>" & xmlhttp.responseText & "</Result>"

%>

In this example, the content must be between quotes (") in order to build a correct SQL statement: for this reason the place holder is used with :'$Content'.

Related Topics

Rules Service SOAP Error Messages

Rules Service SOAP Success Messages