Connecting to a Rules Service via HTTP |
You can access a Rules Service via the HTTP protocol Syntax http://host:port/application/user/response-type/command?$Password=password
response-type := { html | xml | xml-SOAP | plain | composite-type | mime-type }
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. Response-type specifies what type of response is expected as a result of the command. You can encode composite-types such as "text/html", which use a separator forward slash, by encoding the slash symbol as a percentage symbol followed by the symbol's ASCII number in hexadecimal notation. You can encode mime-types such as "img/svg+xml", that use slashes and plus symbols, in a similar way:
Command is the command that you want to pass to the Rules Service. Allowed values for command are:
The query parameter supplying the password is always required. Other query parameters may or may not be required as defined by the command called, or by component specifications in case you call a component.. 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. For this technique, see Example 4.
Example 1 This HTTP call queries all the records in the PERSON table. The result is an HTML-formatted table. http://localhost:7777/TRAVEL/TRAVELUSER/html/query?$Password=TrustMe&$SQL=SELECT * FROM PERSON
Example 2 This HTTP call starts a SQL statement inserting a record in the TOUR table, and then issues a commit: http://localhost:7777/TRAVEL/TRAVELUSER/plain/SqlScript?$Password=TrustMe&$SQL=INSERT INTO tour VALUES('MEXICO','DIVING',4,60);COMMIT
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 DOCUMENT from SVGDOCUMENT where PK=2
Example 3 This HTTP call invokes the query method of USoft's XML internal component. It is equivalent to Example 1: http://localhost:7777/TRAVEL/TRAVELUSER/xml/xml.query?$Password=TrustMe&XmlDocument=<Query><Table Name="PERSON"></Table></Query>
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 this HTTP call: http://localhost:7777/TRAVEL/TRAVELUSER/plain/RulesEngine.RuleProfilerStop?$Password=TrustMe
with resulting text: "Rule profiler stopped successfully". 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 example shows how to use the :$Content placeholder in 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 placeholder is used with :'$Content'.
See Also |