...
- Windows, Linux or Solaris operating system should exist.
- WSO2 BRS should be installed. To install the BRS, refer Installing the Product. This This also includes installing Apache Ant as one one of the Installation Prerequisites.
- WSO2 BRS should be started as described in Running the Product.
...
Deploying and testing the service
- Deploy the rule service through the BRS management console. You can follow either of the two methods:
- Bundle all artifacts in an .aar file and upload it (Rule Service -> Upload menu).
- Create using the Rule Service wizard UI (Rule Service -> Create menu).
The above steps are discussed in detail in section section Exposing Rules as Services .
- After deployment, click on List under Services in the main tab of the management console. The service will appear in the Deployed Services page.
- Click Insurance Service to access the dashboard of the service.
- Click Try this service in the Client Operations widget of the dashboard to invoke the Try-it tool.
Issue a request similar to the following in the Try-it tool.
The Car:Code Block language html/xml <color>red</color> <style>sport</style>
The Driver:
Code Block language html/xml <age>20</age> <name>your name</name> <male>true</male>
You would get the following result:Code Block language xml <premium>120000.0</premium>
Alternatively, you can use Generate Axis2 Client link in the
Client Operations
widget of the dashboard to invoke the service. A client using generated stub codes is shown below where the codes were generated with the Unpacks the data binding classes check box checked.Code Block language java package org.wso2.carbon.samples; import org.apache.axis2.AxisFault; import org.wso2.carbon.samples.insuranceService.insurance.ApplyForInsurance; import org.wso2.carbon.samples.insuranceService.insurance.Car; import org.wso2.carbon.samples.insuranceService.insurance.Driver; import org.wso2.carbon.samples.insuranceService.insurance.Policy; import org.wso2.carbon.samples.insuranceService.stub.InsuranceServiceStub; import java.rmi.RemoteException; public class InsuranceServiceTestCase { public static void main(String[] args) { try { InsuranceServiceStub insuranceServiceStub = new InsuranceServiceStub("http://localhost:9763/services/InsuranceService"); ApplyForInsurance applyForInsurance = new ApplyForInsurance(); Car car = new Car(); car.setColor("red"); car.setStyle("sport"); Car[] cars = new Car[1]; cars[0] = car; Driver driver = new Driver(); driver.setName("your name"); driver.setAge(24); driver.setMale(true); Driver[] drivers = new Driver[1]; drivers[0] = driver; applyForInsurance.setCarInsurance(cars); applyForInsurance.setDriverInsurance(drivers); Policy[] policies = insuranceServiceStub.applyForInsurance(cars, drivers); double result = policies[0].getPremium(); System.out.println(result); } catch (AxisFault axisFault) { axisFault.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } } }
Excerpt hidden true Car insurance service sample of the WSO2 Business Rules Server samples guide.
...