img
. .
Figure 16-14. Testing RESTful-WS using curl with the XML format
As shown in Figure 16-14, the data in XML format was correctly returned. This is because of the
HttpMessageConverters that were defined in the RESTful servlet's WebApplicationContext, while Spring
MVC will invoke the corresponding message converter based on the client's HTTP header's accept
media information and will write to the HTTP response accordingly.
Using RestTemplate to Access RESTful-WS
For Spring-based applications, the RestTemplate class is designed for accessing RESTful web services. In
this section, we will discuss how to use the class to access the contact service on the server.
First let's take a look at the basic ApplicationContext configuration for Spring RestTemplate, as
shown in Listing 16-29 (restful-client-app-context.xml).
Listing 16-29. The restful-client-app-context.xml File
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home