The advantage of using a rigorous and well defined interface, such as a WS-I compliant web service, is the ability to integrate it with other applications using tools to aid that integration. Using HTTP as the communication layer and XML as the request and response formats gives a systems integrator an industry standard way of communicating with the choice of many tools to build that integration.
This tutorial is a quick walkthrough of the direct integration of the Determinations Server running a rulebase with a simple .NET application (written in C Sharp). Integration between the application and the Web Service is handled by a client, automatically generated by Visual Studio 2008. The generated web service client will perform the job of creating the request as a web service call, making the call, and interpreting the response.
This tutorial discusses programming in C#. You should be familiar with C#, and Visual Studio.
The following software is required to follow this tutorial.
This tutorial uses Visual Studio to generate a Service Reference. For more information on how to add a reference to a web service in Visual Studio, see http://msdn.microsoft.com/en-us/library/bb628649.aspx
The first thing to do is to have a look at the SimpleBenefits rulebase in Oracle Policy Modeling. This rulebase is a very simple example. It determines the following 3 goals:
Is the claimant eligible for the low income allowance?
What is the claimant's low income allowance amount?
Is the claimant eligible for the teenage child allowance?
You can compile and run this rulebase in the Determinations Server from Oracle Policy Modeling by the following method:
Visual Studio will create Web Service Client generated from a WSDL. The best way to do this is to do the following:
Now that we have a Reference to the SimpleBenefits rulebase, we can use it in the program. The program in this tutorial will create an assess request, run it against a Determinations Server and prints the results.
The entire class SimpleBenefitsComandLine is provided in Appendix 1 at the end of this document.
There are several steps in writing the program.
In order to use the SimpleBenefits Service Reference client generated code, we need to import it into our class.
using SimpleBenefitsDotNetApp.SimpleBenefitsSpecific;
In the code below, we create the assess request, the session and the entities that we intend to use (session, global, listchild – for holding child entities). All these objects exist within the SimpleBenefits rulebase and also exist as XML elements within the service request that we will send. We will use objects generated as part of the service reference, which match the XML of the request that we need to send./
If this were a real application, it would probably collect information on the claimant and the children from a user interface, or perhaps load them from a database. To keep things simple, we will just hard-code the values for the claimant and his/her two children.
Each entity instance needs a unique id to identify it. If the data was coming from a database, we would probably use primary keys for the ids of the entities, but, again, to keep things simple, we will set them to "global", "child1"and "child2" respectively.
AssessRequest request = new AssessRequest();
request.globalinstance = new GlobalInstanceType();
request.globalinstance.listchild = new childEntityListType();
childInstanceType child1 = new childInstanceType();
child1.id = "child1";
childInstanceType child2 = new childInstanceType();
child2.id = "child2";
request.globalinstance.listchild.child = new childInstanceType[] { child1, child2 };
Before we send the request we need to add the outcomes that we want the Determinations Server to return. In this case, there are three outcomes that we want:
- Is the claimant eligible for the low income allowance?
- The claimants low income allowance payment
- Is the claimant eligible for the teenage child allowance?
To request outcomes for these 3 attributes, we add each attribute, and, instead of providing a value, we set the outcome style. This indicates that instead of providing a value we are asking for the Determinations Server to return the value.
In this case we are only interested in the answer, so the outcome style will be value-only.
GlobalInstanceType g = request.globalinstance;
g.eligible_low_income_allowance = new booleanAttributeType();
g.eligible_low_income_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
g.eligible_low_income_allowance.outcomestyleSpecified = true;
g.low_income_allowance_payment = new numberAttributeType();
g.low_income_allowance_payment.outcomestyle = OutcomeStyleEnum.valueonly;
g.low_income_allowance_payment.outcomestyleSpecified = true;
g.eligible_teenage_allowance = new booleanAttributeType();
g.eligible_teenage_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
g.eligible_teenage_allowance.outcomestyleSpecified = true;
Note:
because the attribute "outcome-style" is an optional attribute, when we set this attribute, we also need to indicate that we have specified the attribute by setting the property outcomestyleSpecified to true.
Now we will set the values that we know: the claimant's income, whether the claimant is a public housing client and the ages of the children. These are attributes in the Rulebase, and also in the generated service reference - attributes of the Global entity (for the claimant) and the child entity (the child's age).
g.claimant_income = new numberAttributeType();
g.claimant_income.Item = new Decimal(13000.00);
g.claimant_public_housing_client = new booleanAttributeType();
g.claimant_public_housing_client.Item = true;
child1.child_age = new numberAttributeType();
child1.child_age.Item = new Decimal(16);
child2.child_age = new numberAttributeType();
child2.child_age.Item = new Decimal(8);
The request is complete and ready to send. We create a specific service instance and call the assess method.
odsAssessServiceSpecific_SimpleBenefits_typeClient service
= new odsAssessServiceSpecific_SimpleBenefits_typeClient();
AssessResponse response = service.Assess(request);
When the Response document is returned, we can now process it for the outcomes that were in the request. If this were a real application, the outcomes would probably be displayed to the user, or persisted to the database. In this case we will simply print them out.
booleanAttributeType lowIncomeAllowance = response.globalinstance.eligible_low_income_allowance;
numberAttributeType lowIncomeAllowancePayment = response.globalinstance.low_income_allowance_payment;
booleanAttributeType teenageAllowance = response.globalinstance.eligible_teenage_allowance;
Console.WriteLine("\n--- Results ----");
if (lowIncomeAllowance.Item is Boolean)
{
Console.WriteLine("low_income_allowance_payment = "
+ lowIncomeAllowance.Item);
}
else if (lowIncomeAllowance.Item is UnknownValue)
{
Console.WriteLine("low_income_allowance_payment is unknown");
}
else if (lowIncomeAllowance.Item is UncertainValue)
{
Console.WriteLine("low_income_allowance_payment is uncertain");
}
if (lowIncomeAllowancePayment.Item is Decimal)
{
Console.WriteLine("eligible_low_income_allowance = "
+ lowIncomeAllowancePayment.Item);
}
else if (lowIncomeAllowancePayment.Item is UnknownValue)
{
Console.WriteLine("eligible_low_income_allowance is unknown");
}
else if (lowIncomeAllowancePayment.Item is UncertainValue)
{
Console.WriteLine("eligible_low_income_allowance is uncertain");
}
if (teenageAllowance.Item is Boolean)
{
Console.WriteLine("eligible_teenage_allowance = "
+ teenageAllowance.Item);
}
else if (teenageAllowance.Item is UnknownValue)
{
Console.WriteLine("eligible_teenage_allowance is unknown");
}
else if (teenageAllowance.Item is UncertainValue)
{
Console.WriteLine("eligible_teenage_allowance is uncertain");
}
When you run the program you should get the following output printed to standard out.
From the response, we can see that all outcomes are known and that the claimant is eligible for both allowances and that the low income allowance payment is 70.0.
---- Starting new SimpleBenefitsAssess (Specific) ----
Creating new Assess request
Setting attribute outcomes for 'eligible_low_income_allowance',
' low_income_allowance_payment', and 'eligible_teenage_allowance'
Setting claimant_income to 13000.00
Setting claimant_public_housing_client to true
Setting child_age on child1 to 16
Setting child_age on child2 to 8
---- Request Sent to Oracle Determinations Server ----
---- Response from Oracle Determinations Server ----
--- Results ----
low_income_allowance_payment = True
eligible_low_income_allowance = 70.0
eligible_teenage_allowance = True
The endpoint of your rulebase running in the Oracle Determination Server will change when you move it to a different server, or you change some other aspect of the deployment like the port the Determinations Server runs on. For example, you may write your integration code against the Determinations Server deployed in a test environment, and, of course, you want your code to run against the production deployment when it is released.
The endpoint for a Service Reference is stored in the app.config file for the program. In Visual Studio, you should be able to see a file in your project called app.config. If you open that file, you should be able to a section starting with the client element.
In the endpoint element, you should be able to see details of the service endpoint, including the URL to run against. You can change this XML to match the Determinations Server that you want to run against.
You should only need to change the address attribute of the endpoint element
<client>
<endpoint address="http://localhost:9000/determinations-server9000/assess/soap/generic/SimpleBenefits"
binding="basicHttpBinding”
bindingConfiguration="odsAssessServiceGeneric_SimpleBenefits"
contract="SimpleBenefitsGeneric.odsAssessServiceGeneric_SimpleBenefits_type"
name="odsAssessServiceGeneric_SimpleBenefits_SOAP" />
</client>
In the tutorial above, we created and used a Web Service Reference client compiled against the Specific wsdl of the SimpleBenefits rulebase. The procedure for creating a client against the Generic wsdl is an identical one, although the Web Service Reference client will be different, and require different code to achieve the same effect.
To complete this tutorial against the Generic wsdl, you should follow the steps above but with the following differences.
Follow the steps outlined in 1 Compile and run SimpleBenefits, but instead of clicking the specific WSDL, click the generic WSDL, which has the form /<determinations-server-url><port>/assess/soap/specific/<rulebase name>?wsdl, or, in the case of this example:
/determinations-server9000/assess/soap/generic/SimpleBenefits?wsdl
Follow the steps outlined in 3 Add a Service Reference for the Determinations Server Specific Client, but for the generic wsdl instead of the specific.
![]()
This is the significantly different part for the Reference generated against the generic service. Although the steps are the same, the code needed to get the same result will be different.
1. Import the generated java client code
The generic namespace will be different from the specific namespace. In order to use the JAX-WS generated code, we need to import it into our class
using SimpleBenefitsDotNetApp.SimpleBenefitsGeneric;
using Attribute=SimpleBenefitsDotNetApp.SimpleBenefitsGeneric.AttributeType;
2. Create the assess and the entities that you will need for the request needs
The code for creating entity instances is a little different for the generic service. All entity instances must be contained into the entity’s instance array. And the entity id should always be populated.
From the code below, you can see that you need a few more lines to create the entity instances for the generic service.
AssessRequest request = new AssessRequest();
request.globalinstance = new GlobalInstanceType();
EntityType childEntity = new EntityType();
childEntity.id = "child";
request.globalinstance.entity = new EntityType[] { childEntity };
EntityInstanceType child1 = new EntityInstanceType();
child1.id = "child1";
EntityInstanceType child2 = new EntityInstanceType();
child2.id = "child2";
childEntity.instance = new EntityInstanceType[] { child1, child2 };
3. Specify the outcomes (answers) that we want the Determinations Server to answer
Creating outcomes for the generic client also requires a few more lines of code. It requires creating new instances of Attribute and setting the id, outcomestyle and outcomestyleSpecified properties.
Attribute eligible_low_income_allowance = new Attribute();
eligible_low_income_allowance.id = "eligible_low_income_allowance";
eligible_low_income_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
eligible_low_income_allowance.outcomestyleSpecified = true;
Attribute low_income_allowance_payment = new Attribute();
low_income_allowance_payment.id = "low_income_allowance_payment";
low_income_allowance_payment.outcomestyle = OutcomeStyleEnum.valueonly;
low_income_allowance_payment.outcomestyleSpecified = true;
Attribute eligible_teenage_allowance = new Attribute();
eligible_teenage_allowance.id = "eligible_teenage_allowance";
eligible_teenage_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
eligible_teenage_allowance.outcomestyleSpecified = true;
4. Set attributes of the entities
When we create attributes for the generic client we create "Attribute" objects and set the id for the Attribute to the public name of the rulebase attribute. We also have to specify for each attribute, what value type it will use (ItemChoiceType)
Attribute claimant_income = new Attribute();
claimant_income.id = "claimant_income";
claimant_income.Item = new Decimal(13000);
claimant_income.ItemElementName = ItemChoiceType.numberval;
Attribute claimant_public_housing_client = new Attribute();
claimant_public_housing_client.id = "claimant_public_housing_client";
claimant_public_housing_client.Item = true;
claimant_public_housing_client.ItemElementName = ItemChoiceType.booleanval;
g.attribute = new Attribute[] { eligible_low_income_allowance,
low_income_allowance_payment,
eligible_teenage_allowance,
claimant_income,
claimant_public_housing_client
};
Attribute child1_age = new Attribute();
child1_age.id = "child_age";
child1_age.Item = new Decimal(16);
child1_age.ItemElementName = ItemChoiceType.numberval;
child1.attribute = new Attribute[] { child1_age };
Attribute child2_age = new Attribute();
child2_age.id = "child_age";
child2_age.Item = new Decimal(8);
child2_age.ItemElementName = ItemChoiceType.numberval;
child2.attribute = new Attribute[] { child2_age };
5. Call the assess method
Calling the assess method in the generic service is almost identical to the specific method, although the names are different.
odsAssessServiceGeneric_SimpleBenefits_typeClient service = new
odsAssessServiceGeneric_SimpleBenefits_typeClient();
AssessResponse response = service.Assess(request);
6. Process the response
Once the response has been returned by the rulebase, we need to process the response to get the answers to the questions that we asked. This requires a little more code in the generic format because the generic XML does not distinguish between different types of entities, and it does not have specific names for the attributes we need to get.
However, by adding some simple methods to look for the attributes and entities that we need, we can simplify the code.
For details on the very simple method GetAttribute, see the full listing of the code in the Appendix below
Attribute eligibleLowIncomeAllowance = GetAttribute(response, "eligible_low_income_allowance");
Attribute lowIncomeAllowancePayment = GetAttribute(response, "low_income_allowance_payment");
Attribute eligibleTeenageAllowance = GetAttribute(response,"eligible_teenage_allowance");
Console.WriteLine("\n---- Results ----");
if (eligibleLowIncomeAllowance.Item is Boolean)
{
Console.WriteLine("eligible_low_income_allowance = " +
eligibleLowIncomeAllowance.Item);
}
else if (eligibleLowIncomeAllowance.Item is UnknownValue)
{
Console.WriteLine("eligible_low_income_allowance is unknown");
}
else if (eligibleLowIncomeAllowance.Item is UncertainValue)
{
Console.WriteLine("eligible_low_income_allowance is uncertain");
}
if (lowIncomeAllowancePayment.Item is Decimal)
{
Console.WriteLine("low_income_allowance_payment = " +
lowIncomeAllowancePayment.Item);
}
else if (lowIncomeAllowancePayment.Item is UnknownValue)
{
Console.WriteLine("low_income_allowance_payment is unknown");
}
else if (lowIncomeAllowancePayment.Item is UncertainValue)
{
Console.WriteLine("low_income_allowance_payment is uncertain");
}
if (eligibleTeenageAllowance.Item is Boolean)
{
Console.WriteLine("eligible_teenage_allowance = " +
eligibleTeenageAllowance.Item);
}
else if (eligibleTeenageAllowance.Item is UnknownValue)
{
Console.WriteLine("eligible_teenage_allowance is unknown");
}
else if (eligibleTeenageAllowance.Item is UncertainValue)
{
Console.WriteLine("eligible_teenage_allowance is uncertain");
}
When you run the generic version of this simple program, you should get the following output printed to standard out. From the response, the results are exactly the same as the specific program.
---- Starting new SimpleBenefitsAssess (Generic) ----
Creating new Assess request
Setting attribute outcomes for 'eligible_low_income_allowance', 'low_income_allowance_payment', and 'eligible_teenage_allowance'
Setting claimant_income to 13000.00
Setting claimant_public_housing_client to true
Setting child_age on child1 to 16
Setting child_age on child2 to 8
---- Request Sent to Oracle Determinations Server ----
---- Response from Oracle Determinations Server ----
---- Results ----
eligible_low_income_allowance = True
low_income_allowance_payment = 70.0
eligible_teenage_allowance = True
As you can see for both examples you can follow the same steps to generate and use an JAX-WS Java client for a rulebase deployed on the Determinations Server. You can use either client to achieve the desired operation.
The major difference between the specific and the generic client is ease of use versus maintainability. The specific format is easier to use and much less prone to error, because attributes and relationships have specific names within the rulebase. You cannot accidently misname at attribute or a relationship using the specific format. The disadvantage with the Specific format is that adding, removing or renaming attributes and relationships will require you to regenerate the Java client using the JAX-WS wsimport tool.
The interface generated for the generic client however, can be used for any rulebase, and never needs to be recompiled. Its disadvantage is that it is easier to make mistakes with the names of attributes and relationships and the code is somewhat more cumbersome.
.NET – A framework provided by Microsoft for building applications. For more information on .NET see http://www.microsoft.com/net/
C# (Sharp) – A programming language created by Microsoft. See: http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx
End Point – An address that can be used to communicate with a web service. For this tutorial the end point is the location of the SimpleBenefits rulebase when deployed to the Oracle Determinations Server.
Oracle Determinations Server – A web application which provides Oracle Policy Automation services as a web service.
Rulebase – A compiled rule project authored in Oracle Policy Modeling.
Service Reference – In Visual Studio, this is a reference to an external Service. In the context of this tutorial the service is a Web Service.
URL – Uniform Resource Locator. A global address for documents and services on the World Wide Web
Web Service – A service provided over the Web. Typically using XML and SOAP.
WSDL – Web Service Description Language. A standard way of describing Web Services that user XML and SOAP
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleBenefitsDotNetApp.SimpleBenefitsSpecific;
namespace SimpleBenefitsDotNetApp
{
/// <summary>
/// Tutorials and Examples - Create and use a C# client for Oracle Determinations Server
/// using a specific WSDL
/// </summary>
class SimpleBenefitsSpecificCommandLine
{
/// <summary>
/// Assess request processing for the SimpleBenefits rulebase using a specific WSDL
/// </summary>
static void Main(string[] args)
{
try
{
Console.WriteLine("---- Starting new SimpleBenefitsAssess (Specific) ----");
Console.WriteLine("Creating new Assess request");
// Create the assess and the entities that you will need for the request needs
AssessRequest request = new AssessRequest();
request.globalinstance = new GlobalInstanceType();
request.globalinstance.listchild = new childEntityListType();
childInstanceType child1 = new childInstanceType();
child1.id = "child1";
childInstanceType child2 = new childInstanceType();
child2.id = "child2";
request.globalinstance.listchild.child
= new childInstanceType[] { child1, child2 };
Console.WriteLine("Setting attribute outcomes for "
+ "'eligible_low_income_allowance', "
+ "'low_income_allowance_payment', "
+ "and 'eligible_teenage_allowance'");
// Specify the outcomes (answers) that we want the Determinations Server to answer
GlobalInstanceType g = request.globalinstance;
g.eligible_low_income_allowance = new booleanAttributeType();
g.eligible_low_income_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
g.eligible_low_income_allowance.outcomestyleSpecified = true;
g.low_income_allowance_payment = new numberAttributeType();
g.low_income_allowance_payment.outcomestyle = OutcomeStyleEnum.valueonly;
g.low_income_allowance_payment.outcomestyleSpecified = true;
g.eligible_teenage_allowance = new booleanAttributeType();
g.eligible_teenage_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
g.eligible_teenage_allowance.outcomestyleSpecified = true;
// Set attributes and relationships of the entities
Console.WriteLine("Setting claimant_income to 13000.00");
g.claimant_income = new numberAttributeType();
g.claimant_income.Item = new Decimal(13000.00);
Console.WriteLine("Setting claimant_public_housing_client to true");
g.claimant_public_housing_client = new booleanAttributeType();
g.claimant_public_housing_client.Item = true;
Console.WriteLine("Setting child_age on child1 to 16");
child1.child_age = new numberAttributeType();
child1.child_age.Item = new Decimal(16);
Console.WriteLine("Setting child_age on child2 to 8");
child2.child_age = new numberAttributeType();
child2.child_age.Item = new Decimal(8);
odsAssessServiceSpecific_SimpleBenefits_typeClient service = new odsAssessServiceSpecific_
SimpleBenefits_typeClient();
// Call the assess method
AssessResponse response = service.Assess(request);
Console.WriteLine("\n---- Request Sent to Oracle Determinations Server ----");
// Process the reponse
Console.WriteLine("\n---- Response from Oracle Determinations Server ----");
// look for the outcomes
booleanAttributeType lowIncomeAllowance = response.globalinstance.eligible_low_income_
allowance;
numberAttributeType lowIncomeAllowancePayment = response.globalinstance.low_income_
allowance_payment;
booleanAttributeType teenageAllowance = response.globalinstance.eligible_teenage_allowance;
// print out the results
Console.WriteLine("\n---- Results ----");
if (lowIncomeAllowance.Item is Boolean)
{
Console.WriteLine("low_income_allowance_payment = " + lowIncomeAllowance.Item);
}
else if (lowIncomeAllowance.Item is UnknownValue)
{
Console.WriteLine("low_income_allowance_payment is unknown");
}
else if (lowIncomeAllowance.Item is UncertainValue)
{
Console.WriteLine("low_income_allowance_payment is uncertain");
}
if (lowIncomeAllowancePayment.Item is Decimal)
{
Console.WriteLine("eligible_low_income_allowance = " + lowIncomeAllowancePayment.Item);
}
else if (lowIncomeAllowancePayment.Item is UnknownValue)
{
Console.WriteLine("eligible_low_income_allowance is unknown");
}
else if (lowIncomeAllowancePayment.Item is UncertainValue)
{
Console.WriteLine("eligible_low_income_allowance is uncertain");
}
if (teenageAllowance.Item is Boolean)
{
Console.WriteLine("eligible_teenage_allowance = " + teenageAllowance.Item);
}
else if (teenageAllowance.Item is UnknownValue)
{
Console.WriteLine("eligible_teenage_allowance is unknown");
}
else if (teenageAllowance.Item is UncertainValue)
{
Console.WriteLine("eligible_teenage_allowance is uncertain");
}
}
catch (Exception e)
{
Console.WriteLine("Error occurred " + e.Message);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleBenefitsDotNetApp.SimpleBenefitsGeneric;
using Attribute = SimpleBenefitsDotNetApp.SimpleBenefitsGeneric.AttributeType;
namespace SimpleBenefitsDotNetApp
{
/// <summary>
/// Tutorials and Examples - Create and use a C# client for Oracle Determinations Server
/// using a generic WSDL
/// </summary>
class SimpleBenefitsGenericCommandLine
{
/// <summary>
/// Retrieves a specific attribute from the global instance of the response
/// </summary>
/// <param name="response">the assess response</param>
/// <param name="id">the id of the attribute to retrieve</param>
/// <returns>the attribute</returns>
private static Attribute GetAttribute(AssessResponse response, string id)
{
foreach (Attribute attribute in response.globalinstance.attribute)
{
if (attribute.id.Equals(id))
{
return attribute;
}
}
return null;
}
/// <summary>
/// Assess request processing for the SimpleBenefits rulebase using a generic WSDL
/// </summary>
/// <param name="args">arguments</param>
static void Main(string[] args)
{
try
{
Console.WriteLine("---- Starting new SimpleBenefitsAssess (Generic) ----");
// Create the assess and the entities that you will need for the request needs
Console.WriteLine("Creating new Assess request");
AssessRequest request = new AssessRequest();
request.globalinstance = new GlobalInstanceType();
EntityType childEntity = new EntityType();
childEntity.id = "child";
request.globalinstance.entity = new EntityType[] { childEntity };
EntityInstanceType child1 = new EntityInstanceType();
child1.id = "child1";
EntityInstanceType child2 = new EntityInstanceType();
child2.id = "child2";
childEntity.instance = new EntityInstanceType[] { child1, child2 };
// Specify the outcomes(answers) that we want the Oracle Determinations Server to answer
GlobalInstanceType g = request.globalinstance;
Console.WriteLine("Setting attribute outcomes for "
+ "'eligible_low_income_allowance', "
+ "'low_income_allowance_payment', "
+ "and 'eligible_teenage_allowance'");
Attribute eligible_low_income_allowance = new Attribute();
eligible_low_income_allowance.id = "eligible_low_income_allowance";
eligible_low_income_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
eligible_low_income_allowance.outcomestyleSpecified = true;
Attribute low_income_allowance_payment = new Attribute();
low_income_allowance_payment.id = "low_income_allowance_payment";
low_income_allowance_payment.outcomestyle = OutcomeStyleEnum.valueonly;
low_income_allowance_payment.outcomestyleSpecified = true;
Attribute eligible_teenage_allowance = new Attribute();
eligible_teenage_allowance.id = "eligible_teenage_allowance";
eligible_teenage_allowance.outcomestyle = OutcomeStyleEnum.valueonly;
eligible_teenage_allowance.outcomestyleSpecified = true;
// Set attributes of the entities
Console.WriteLine("Setting claimant_income to 13000.00");
Attribute claimant_income = new Attribute();
claimant_income.id = "claimant_income";
claimant_income.Item = new Decimal(13000);
claimant_income.ItemElementName = ItemChoiceType.numberval;
Console.WriteLine("Setting claimant_public_housing_client to true");
Attribute claimant_public_housing_client = new Attribute();
claimant_public_housing_client.id = "claimant_public_housing_client";
claimant_public_housing_client.Item = true;
claimant_public_housing_client.ItemElementName = ItemChoiceType.booleanval;
g.attribute = new Attribute[] { eligible_low_income_allowance,
low_income_allowance_payment,
eligible_teenage_allowance,
claimant_income,
claimant_public_housing_client
};
Console.WriteLine("Setting child_age on child1 to 16");
Attribute child1_age = new Attribute();
child1_age.id = "child_age";
child1_age.Item = new Decimal(16);
child1_age.ItemElementName = ItemChoiceType.numberval;
child1.attribute = new Attribute[] { child1_age };
Console.WriteLine("Setting child_age on child2 to 8");
Attribute child2_age = new Attribute();
child2_age.id = "child_age";
child2_age.Item = new Decimal(8);
child2_age.ItemElementName = ItemChoiceType.numberval;
child2.attribute = new Attribute[] { child2_age };
// Call the assess method
odsAssessServiceGeneric_SimpleBenefits_typeClient service = new odsAssessServiceGeneric_
SimpleBenefits_typeClient();
AssessResponse response = service.Assess(request);
Console.WriteLine("\n---- Request Sent to Oracle Determinations Server ----");
// Process the reponse
Console.WriteLine("\n---- Response from Oracle Determinations Server ----");
Attribute eligibleLowIncomeAllowance = GetAttribute(response, "eligible_low_income_allowance");
Attribute lowIncomeAllowancePayment = GetAttribute(response, "low_income_allowance_
payment");
Attribute eligibleTeenageAllowance = GetAttribute(response, "eligible_teenage_allowance");
Console.WriteLine("\n---- Results ----");
if (eligibleLowIncomeAllowance.Item is Boolean)
{
Console.WriteLine("eligible_low_income_allowance = " + eligibleLowIncomeAllowance.Item);
}
else if (eligibleLowIncomeAllowance.Item is UnknownValue)
{
Console.WriteLine("eligible_low_income_allowance is unknown");
}
else if (eligibleLowIncomeAllowance.Item is UncertainValue)
{
Console.WriteLine("eligible_low_income_allowance is uncertain");
}
if (lowIncomeAllowancePayment.Item is Decimal)
{
Console.WriteLine("low_income_allowance_payment = "
+ lowIncomeAllowancePayment.Item);
}
else if (lowIncomeAllowancePayment.Item is UnknownValue)
{
Console.WriteLine("low_income_allowance_payment is unknown");
}
else if (lowIncomeAllowancePayment.Item is UncertainValue)
{
Console.WriteLine("low_income_allowance_payment is uncertain");
}
if (eligibleTeenageAllowance.Item is Boolean)
{
Console.WriteLine("eligible_teenage_allowance = " + eligibleTeenageAllowance.Item);
}
else if (eligibleTeenageAllowance.Item is UnknownValue)
{
Console.WriteLine("eligible_teenage_allowance is unknown");
}
else if (eligibleTeenageAllowance.Item is UncertainValue)
{
Console.WriteLine("eligible_teenage_allowance is uncertain");
}
}
catch (Exception e)
{
Console.WriteLine("Error occurred " + e.Message);
}
}
}
}