Java Reference
In-Depth Information
invocation point. Clients request interactions with those objects using HTTP methods
such as GET , PUT , or DELETE . RESTful applications may use SOAP, but the strong inclina-
tions toward parsimony in RESTful services lead many architects to use simple,
homegrown XML representations of objects.
While large web services use a hierarchy of World Wide Web Consortium (W3C)
protocols including UDDI, WSDL, and SOAP, it's entirely possible for you to build a web
service using only XML. Many popular Web 2.0 services used in software mashups do
this, eschewing the complexity of the full W3C stack for lightweight object representation
based solely on SOAP or occasionally just an application of XML alone. Increasingly, web
services may provide support for other structured data representations, such as JSON or
YAML, enabling software developers to capitalize on the support for these newer data
representations in programming languages such as JavaScript or Ruby.
Tip While there's no reason why you can't build on or use a web service that provides JSON or YAML
interfaces with your Java ME application, you should be prepared to do more work to support these data
representations, because there's little support on the Java ME platform for them as I write this. I imagine that
this situation is likely to change in the coming years as more services use these representations in their
client/server communication.
Exchanging Data over the Network
If you're writing a client for any of today's web services, odds are that you will use
either HTTP or HTTPS. As I noted in the previous chapter in the section “Securing
Your HTTP Transaction with HTTPS,” HTTP is a good protocol for data exchange, but
it's not terribly secure. Many web services, including those for e-commerce, almost
certainly use HTTPS. It's important to remember that not only do you need to protect
the security of your users' data with HTTPS, but you also need to take responsibility
for protecting their data elsewhere in your application, such as when it's stored in a
record store or file.
Another consideration when writing web service clients is the HTTP methods you
may need to use; this is especially true when using REST, because the REST paradigm
relies on the HTTP method to provide some of the semantics about a web service opera-
tion. For example, in writing a web service client to a messaging application that's built
around REST, you may find that the web service definition for deleting a message
requires that you send an HTTP request with the DELETE method. Fortunately, this is as
easy as specifying the method using the HttpConnection 's (or HttpsConnection 's )
setRequestMethod passing the method you want to use, as shown in Listing 13-1.
 
Search WWH ::




Custom Search