...
Deploying and Testing the Service
1. 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 Exposing Rules as Services.
2. After deployment, the service will appear in the Deployed Services window of the BRS management console. Access the service's dashboard by clicking on it.
3. In the Client Operations
widget of the dashboard, invoke the Try-it toolTesting WSDLs (Try-it Tool) to to test the service.
4. In the service's Try-it window, issue a request similar to the following.
Code Block | ||
---|---|---|
| ||
<loanType>FHA</loanType> <mortgageValue>100000</mortgageValue> <downPayment>90000</downPayment> |
Code Block | ||
---|---|---|
| ||
<loanType>PMI</loanType> <mortgageValue>100000</mortgageValue> <downPayment>90000</downPayment> |
5. Alternatively, you can use code generation 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 option "Unpacks the databinding classes".
Code Block | ||
---|---|---|
| ||
package org.wso2.carbon.samples; import org.apache.axis2.AxisFault; import org.wso2.carbon.samples.mipCalculateService.clientDetail.Client; import org.wso2.carbon.samples.mipCalculateService.clientDetail.MIP; import org.wso2.carbon.samples.mipCalculateService.clientDetail.PlaceClientDetail; import org.wso2.carbon.samples.mipCalculateService.stub.MIPCalculateServiceStub; import java.rmi.RemoteException; public class MIPCalculateServiceTestCase { public static void main(String[] args) { try { MIPCalculateServiceStub mipCalculateServiceStub = new MIPCalculateServiceStub("http://localhost:9763/services/MIPCalculateService"); PlaceClientDetail placeClientDetail = new PlaceClientDetail(); Client client = new Client(); client.setLoanType("FHA"); client.setDownPayment(8000); client.setMortgageValue(90000); Client[] clients = new Client[1]; clients[0] = client; MIP[] mips = mipCalculateServiceStub.calculate(clients); double result = mips[0].getAnnualMIP(); System.out.println(result); } catch (AxisFault axisFault) { axisFault.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } } } |
Excerpt | ||
---|---|---|
| ||
Mortgage insurance premium calculation service sample of the WSO2 Business Rules Server samples guide. |