img
Listing 16-27. curl Command for Testing RESTful-WS
curl -v -H "Accept: application/json" http://localhost:8080/ch16/restful/contact/listdata
The command in Listing 16-27 will send an HTTP request to the server's RESTful web service; in this
case, it will invoke the listData() method in ContactController to retrieve and return all contact
information. Also, the ­H option declares an HTTP header attribute, meaning that the client wants to
receive data in JSON format. Running the command will produce the output shown in Figure 16-13.
Figure 16-13. Testing RESTful-WS using curl with the JSON format
In Figure 16-13, you can see that the data in JSON format for the initially populated contact
information was returned. Now let's take a look at the XML format; the command is shown in Listing
16-28.
Listing 16-28. curl Command for Testing RESTful-WS
curl -v -H "Accept: application/xml" http://localhost:8080/ch16/restful/contact/listdata
As shown in Listing 16-28, there is only one difference compared to Listing 16-27. The accept media
was changed from JSON to XML. Running the command will produce the output shown in Figure 16-14.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home