Calling the SOAP EndPoint using a Service Reference

  • Updated

Prerequisites: A valid Service Reference
See Also: irServer - Rule Execution Service

The following sample represents how to call irServer Rule Execution Service SOAP EndPoint using a service reference:

using (RuleEngineServiceClient proxy = new RuleEngineServiceClient())
{
 try
 {
         // Get RuleApp as defined in the config (RepositoryRuleApp or FileSystemRuleApp)
         RepositoryRuleApp rules = new RepositoryRuleApp();
         rules.RepositoryServiceUri = "http://server/InRuleCatalogService/Service.svc";
         RepositoryRuleAppRevisionSpec spec = new RepositoryRuleAppRevisionSpec();
         spec.RuleApplicationName = "MortgageCalculator";
         rules.RepositoryRuleAppRevisionSpec = spec;
         rules.UserName = "Admin";
         rules.Password = "password";

         // Create new ApplyRulesRequest
         ApplyRulesRequest request = new ApplyRulesRequest();
         request.RuleApp = rules;
         request.EntityName = "Mortgage";
         request.RuleEngineServiceOutputTypes = new RuleEngineServiceOutputTypes();
         request.RuleEngineServiceOutputTypes.ActiveNotifications = true;
         request.RuleEngineServiceOutputTypes.ActiveValidations = true;
         request.RuleEngineServiceOutputTypes.EntityState = true

         // Load state XML
         Console.WriteLine("- Loading XML state for 'Invoice'...");
         request.EntityState =
"<Mortgage><LoanInfo><Principal>500000</Principal><APR>6.875</APR
< TermInYears > 30 </TermInYears ></LoanInfo ><PaymentSummary/ ></Mortgage > "
;
         Console.WriteLine("Input State:");
         Console.WriteLine(request.EntityState);
         Console.WriteLine("");

         // Submit Request
         Console.WriteLine("- Calling ApplyRules() from RuleEngineService...");
         RuleEngineServiceResponse response = proxy.ExecuteRuleEngineRequest(request)

         Console.WriteLine("Active Notifications:");
         foreach (Notification notification in response.ActiveNotifications)
         {
                 Console.WriteLine(notification.NotificationType + ": " + notification.Message);
         }
         Console.WriteLine("");
         
Console.WriteLine("Active Validations:");
         foreach (Validation validation in response.ActiveValidations)
         {
                 Console.WriteLine(validation.InvalidMessageText);
         }
         Console.WriteLine("");
         Console.WriteLine("Output State:");
         // Note: XML formatting not maintained in response
         Console.WriteLine(response.EntityState);
         Console.WriteLine("");
 }
 catch (Exception ex)
 {
         Console.WriteLine("Unknown exception occurred during RuleEngineService request: " +
ex.ToString());
 }
}
Console.WriteLine("[END ServiceReferenceConsumer Sample]")

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.