...
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 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 HealthCare 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.
Code Block language html/xml <medication>Cefuroxime</medication> <age>54</age> <creatinineLevel>1.2</creatinineLevel>
The response would be as follows:
Code Block language html/xml <message>250 mg every 24 hours for 14 days</message>
Send another request as follows:
Code Block language html/xml <medication>Amoxicillin</medication> <age>20</age>
You would get the following response:Code Block language html/xml <message>500 mg every 24 hours for 14 days</message>
Alternatively, you can click Generate Axis2 Client 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 databinding classes check box checked.
Code Block language java package org.wso2.carbon.samples; import org.apache.axis2.AxisFault; import org.wso2.carbon.samples.healthCareService.patientDetail.Dose; import org.wso2.carbon.samples.healthCareService.patientDetail.Patient; import org.wso2.carbon.samples.healthCareService.patientDetail.PatientDetail; import org.wso2.carbon.samples.healthCareService.stub.HealthCareServiceStub; import java.rmi.RemoteException; public class HealthCareServiceTestCase { public static void main(String[] args) { try { HealthCareServiceStub healthCareServiceStub = new HealthCareServiceStub("http://localhost:9763/services/HealthCareService"); PatientDetail patientDetail = new PatientDetail(); Patient patient = new Patient(); patient.setAge(43); patient.setCreatinineLevel(1.0); patient.setMedication("Levofloxacin"); Patient[] patients = new Patient[1]; patients[0] = patient; patientDetail.setPatientDetail(patients); Dose[] doses = healthCareServiceStub.recommendDose(patients); String result = doses[0].getMessage(); System.out.println(result); } catch (AxisFault axisFault) { axisFault.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } }
Excerpt hidden true HealthCare service sample of the WSO2 Business Rules Server samples guide.
...