Postman is a third party tool often used to test calling REST services. This post will give a quick demonstration of using Postman to call InRule’s “out-of-the-box” irServer® Rule Execution Service using its REST endpoint, which can be installed using the InRule installer.
In this demonstration, I will first create a new rule application using irAuthor®, store it in irCatalog®, and then use Postman to execute the rule application using the irServer® Rule Execution Service.
Installing InRule
This demonstration will use three components, which are highlighted in the screen shot below:
Hello World!
We’ll start by authoring a simple rule application and storing it in irCatalog.
Here are the steps I took to do this:
- Launched irAuthor.
- On the Start page, clicked New Rule Application.
- On the Settings page, changed the name of the rule application from NewRuleApplication to HelloWorld.
- In the Entities pane, right-clicked on Entity1, and added a new field called Field1
- Added a new rule to set the value of Field1 to Hello World1, as shown below
- File-Save As, and saved the rule application to a local irCatalog service.
To save the rule application in irCatalog, I just select File->Save-As, and connect to my local irCatalog service.
I’ll now click the “Test” button to launch irVerify and click the “Apply Rules” button to test out the rule. As you can see below, it ran the rule and set Field1 to “Hello World!”
Setting the Credentials in the web.config file
I opened my Rule Execution Service web.config which I found here on my machine:
C:\Program Files\InRule_v5.7.3\irServer\RuleEngineService\IisService\web.config
In the following section, I added my credentials.
<inrule.runtime.service>
<catalog catalogServiceUri="http://localhost/InRuleCatalogService/Service.svc" userName="admin" password="password" allowPerRequestCatalogCredentials="false"/>
...
</inrule.runtime.service>
Calling irServer® Rule Execution Service from Postman
Postman can be downloaded here: https://www.getpostman.com/
To complete this demonstration, I just needed to launch Postman, and set up four things: the HTTP Method, the URL for my local irServer Rule Execution Service instance, the Request, and Headers, as listed below:
The HTTP Method:
POST
The URL:
http://localhost/InRuleRuleEngineService/HttpService.svc/ApplyRules
The Body (using JSON):
{
"RuleApp":
{
"RepositoryRuleAppRevisionSpec":
{ "RuleApplicationName":"HelloWorld" },
"UseIntegratedSecurity":"false"
},
"RuleEngineServiceOptions": { "Overrides": "" },
"RuleEngineServiceOutputTypes":
{
"ActiveNotifications": "false",
"ActiveValidations": "false",
"EntityState": "true",
"Overrides": "false",
"RuleExecutionLog": "false"
},
"EntityName": "Entity1",
"EntityState": "{}"
}
The Header:
Content-Type:application/json
Here is what Postman looks like just before clicking the Send button:
When clicking the Send button, Postman will POST the Request to the URL and get back a response. Here is what Postman looks like after clicking the Send button, and as you can see, it did correctly run the rule and set Field1 to “Hello World!”
Here is the response I got back:
<RuleEngineHttpServiceResponse xmlns=”https://www.inrule.com/XmlSchema/Schema” xmlns:i=”http://www.w3.org/2001/XMLSchema-instance”>
<ActiveNotifications/>
<ActiveValidations/>
<EntityState>{“Field1″:”Hello World!”}</EntityState>
<HasRuntimeErrors>false</HasRuntimeErrors>
<Overrides i:nil=”true”/>
<RequestId>00000000-0000-0000-0000-000000000000</RequestId>
<RuleExecutionLog i:nil=”true”/>
<RuleSessionState i:nil=”true”/>
<SessionId>b62c49ef-d8d9-4647-920a-4d4c63e05707</SessionId>
</RuleEngineHttpServiceResponse>
Comments
0 comments
Please sign in to leave a comment.