More Testing

Aside from Rails functional testing, we can test our service application in other ways as well. The first and easiest is to use ActionWebService scaffolding. This is helpful when we want to see what service request results look like on the fly. Recall in Example 15-9 we declared a scaffold at invoke using the web_service_scaffold method. This defined a set of test web pages accessible at http://localhost/movies_service/invoke. Figure 15-5 shows the sequence of selecting a service method to invoke, setting up parameters for invocation, and receiving the response.

Testing an ActionWebService service with scaffolding

Figure 15-5. Testing an ActionWebService service with scaffolding

Note that if our service is facing the public Internet, we may want to turn this scaffolding off for production use. If that is the case, we can also test the service via a desktop client. On the Mac, a free XML-RPC client is available at http://ditchnet.org/xmlrpc/. To test a service, we define the endpoint URL, the method name, and the parameters. Figure 15-6 shows the sequence of using the desktop client to test a layered service.

Regardless of how we test, the XML generated for requests and responses is the same. The beauty of XML-RPC is that we don’t need to worry about what this looks like. However, for reference, a sample request is shown in Example 15-11 and a sample response in Example 15-12.

Example 15-11. The XML of an XML-RPC ...

Get Enterprise Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.