Java Reference
In-Depth Information
void setTitle(String title) { this.title = title; }
}
Book dependsonan Author class, whosebeansstorethenames ofindividual au-
thors, and which is presented in Listing 11-13 .
Listing 11-13. Library's Author class
public class Author implements java.io.Serializable
{
private String name;
public Author() {}
Author(String name) { setName(name); }
String getName() { return name; }
void setName(String name) { this.name = name; }
}
Now that you understand how the Library web service is implemented, you need
a client to try out this web service. Listing 11-14 's LibraryClient.java source
code demonstrates how a client can access the Library web service via the
java.net.HttpURLConnection class.
Listing 11-14. A client for accessing the Library web service
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
class LibraryClient
{
final static String LIBURI = "http://localhost:9902/lib-
rary";
public static void main(String[] args) throws Exception
{
String book1 = "<?xml version=\"1.0\"?>"+
Search WWH ::




Custom Search