Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Executing the sample

To execute the sample, run the ant command from the  <BRS_Home>/samples/quotation.service directory to run the GetQuote Service.

Deploying and Testing the Service

1.
  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 section  Exposing Rules as Services.
     
2.
  1. After deployment, click on List under Services in the main tab of the management console. The service will appear in
the
  1. the Deployed Services
window
  1.  page.
  2. Click GetQuote Service to access the dashboard of the
BRS management console. Access the
  1. service
's dashboard by clicking on it.3. In the Client Operations widget of the dashboard, invoke the
  1. .
  2. Click Try this service in the Client Operations widget of the dashboard to invoke the Try-it tool
to test the service
  1. .
4. In the service's Try-it window, issue
  1. Issue a request similar to the following in the Try the GetQuote service window.

 

Code Block
languagehtml/xml
<status>bronze</status>
5. Alternatively, you can use Generate 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 option "Unpacks the databinding classes".

 

Code Block
languagejava
package org.wso2.carbon.samples;

import org.apache.axis2.AxisFault;
import org.wso2.carbon.samples.quoteService.customerDetail.Customer;
import org.wso2.carbon.samples.quoteService.customerDetail.PlaceCustomerDetail;
import org.wso2.carbon.samples.quoteService.customerDetail.Quotation;
import org.wso2.carbon.samples.quoteService.stub.GetQuoteServiceStub;
import java.rmi.RemoteException;

public class GetQuoteServiceTestCase {

    public static void main(String[] args) {

        try {
            GetQuoteServiceStub getQuoteServiceStub = new GetQuoteServiceStub("http://localhost:9763/services/GetQuoteService");

            PlaceCustomerDetail placeCustomerDetail = new PlaceCustomerDetail();
            Customer customer = new Customer();
            customer.setStatus("gold");
            Customer[] customers = new Customer[1];
            customers[0] = customer;
            placeCustomerDetail.setCustomerDetail(customers);

            Quotation[] quotations = getQuoteServiceStub.getQuote(customers);
            int result = quotations[0].getPrice();
            System.out.println(result);
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
Excerpt
hiddentrue

GetQuote service sample of the WSO2 Business Rules Server samples guide.