Java Reference
In-Depth Information
After
Classpath
has been configured, you can begin using Apache XML-RPC classes in
your Java programs. The easiest way to refer to these classes is to use an
import
state-
ment to make a package available, as in the following statement:
import org.apache.xmlrpc.*;
This makes it possible to refer to the classes in the main package,
org.apache.xmlrpc
,
without using the full package name. You'll work with this package in the next two
sections.
If Apache XML-RPC doesn't suit your needs, you can choose from
more than two dozen other implementations. XML-RPC.Com
includes a directory of XML-RPC implementations in Java, C++,
PHP, and other languages. To see the list, visit the website
http://www.xmlrpc.com
and choose the Implementations hyper-
link.
NOTE
An XML-RPC client is a program that connects to a server, calls a method on a program
on that server, and stores the result.
Using Apache XML-RPC, the process is comparable to calling any other method in
Java—you don't have to create an XML request, parse an XML response, or connect to
the server using one of Java's networking classes.
In the
org.apache.xmlrpc
package, the
XmlRpcClient
class represents a client. An
XmlRpcClient
object can be created in three ways, each of which requires the URL of
the server:
XmlRpcClient(
String
)
—Create a client connecting to an address specified by the
String
, which must be a valid web address (such as http://www.example.com) or
web address and port number (such as http://www.example.com:2274)
n
XmlRpcClient(
URL
)
—Create a client connecting to the specified
URL
object
n
XmlRpcClient(
String
,
int
)
—Create a client connecting to the specified host-
name (
String
) and port number (
int
)
n
The two constructors that require a
String
argument throw
java.net.
MalformedURLException
exceptions if the argument is not a valid web URL.