Home

 

Testing the services

Before writing any Web pages, we can test the services that we created. Make sure that the WebSphere Application Server v7.0 is started.

To test the services provided by the servlet, execute the following steps:

In the Enterprise Explorer, expand RAD75Web20Dojo, right-click the CustomerServlet (either in the deployment descriptor or the Java class) and select Run As Æ Run on Server.

The application is deployed to the server and the servlet is invoked. The result of the servlet is displayed in Example | 9-7.

Example 19-7 CustomerServlet execution result

{"items":[{"ssn":"000-00-0000"},{"ssn":"111-11-1111"},{"ssn":"222-22-2222"}
,{"ssn":"333-33-3333"},{"ssn":"444-44-4444"},{"ssn":"555-55-5555"},{"ssn":"
666-66-6666"},{"ssn":"777-77-7777"},{"ssn":"888-88-8888"},{"ssn":"999-99-99
99"}],"identifier":"ssn"}

To test the services provided by RPC Adapter, execute the following steps:

In the Services View, expand RPCAdapter Æ RAD75Web20Dojo: CustomerService Æ findCustomerBySsn(String).

Right-click findCustomerBySsn(String) and select Run As Æ Run on Server.

When prompted to save the file, click Cancel.

An information page is displayed, because the parameter is missing.

In the browser URL address, complete the request with a customer SSN:

https://localhost:944x/RAD75Web20Dojo/RPCAdapter/httprpc/CustomerService/findCustomerBySsn?ssn=777-77-7777

Press Enter to send the request.

When prompted to save the file, click Save and navigate to a folder where you can find the findCustomerBySsn file that is created.

Open the file in an editor (Example | 9-8).

Example 19-8 JSON result of getCustomer request

{"result":{"lastName":"Gomes","title":"Mr","firstName":"Miguel","accountCol
lection":[{"transactCollection":null,"id":"007-777001","customerCollection"
:null,"balance":500.00}],"ssn":"777-77-7777"}}

Repeat the test for the getTransactionByAccount method of the TransactionService. Use this URL:

https://localhost:944x/RAD75Web20Dojo/RPCAdapter/httprpc/TransactionService/getTransactionByAccount?account_id=002-222001

The result of this call is:
{"result":[{"transType":"Credit","transTime":"1990-01-01T23:23:23-0800","am
ount":2222.22,"id":"0000001","account":{"transactCollection":null,"id":"002
-222001","customerCollection":null,"balance":65484.23}},......]}
ibm.com/redbooks