org.apache.xmlrpc

Class XmlRpcClient

public class XmlRpcClient extends Object implements XmlRpcHandler

A multithreaded, reusable XML-RPC client object. Use this if you need a full-grown HTTP client (e.g. for Proxy and Basic Auth support). If you don't need that, XmlRpcClientLite may work better for you.

Version: $Id: XmlRpcClient.java 350048 2005-11-30 21:49:32 +0100 (Mi, 30 Nov 2005) jochen $

Author: Hannes Wallnoefer Andrew Evers Ryan Hoegg

Nested Class Summary
classXmlRpcClient.CallData
classXmlRpcClient.XmlRpcClientAsyncThread
Field Summary
protected intasyncWorkers
XmlRpcClient.CallDatafirst
XmlRpcClient.CallDatalast
intmaxThreads
The maximum number of threads which can be used concurrently, by defaut use the one defined in XmlRpc
protected Stackpool
StringstoredPassword
StringstoredUser
protected XmlRpcTransportFactorytransportFactory
TimeZonetz
protected URLurl
protected intworkers
Constructor Summary
XmlRpcClient(URL url, XmlRpcTransportFactory transportFactory)
Construct a XML-RPC client with this URL and a specified transport factory.
XmlRpcClient(URL url)
Construct a XML-RPC client with this URL.
XmlRpcClient(String url)
Construct a XML-RPC client for the URL represented by this String.
XmlRpcClient(String hostname, int port)
Construct a XML-RPC client for the specified hostname and port.
Method Summary
DefaultXmlRpcTransportcreateDefaultTransport()
protected XmlRpcTransportcreateTransport()
XmlRpcClient.CallDatadequeue()
voidenqueue(XmlRpcClient.CallData call)
Objectexecute(String method, Vector params)
Generate an XML-RPC request and send it to the server.
Objectexecute(XmlRpcClientRequest request)
Objectexecute(XmlRpcClientRequest request, XmlRpcTransport transport)
voidexecuteAsync(String method, Vector params, AsyncCallback callback)
Generate an XML-RPC request and send it to the server in a new thread.
voidexecuteAsync(XmlRpcClientRequest request, AsyncCallback callback)
voidexecuteAsync(XmlRpcClientRequest request, AsyncCallback callback, XmlRpcTransport transport)
intgetMaxThreads()
Get the MaxThreads for this Client
TimeZonegetTimeZone()
URLgetURL()
Return the URL for this XML-RPC client.
XmlRpcClientWorkergetWorker(boolean async)
static voidmain(String[] args)
Just for testing.
voidreleaseWorker(XmlRpcClientWorker w, boolean async)
Release possibly big per-call object references to allow them to be garbage collected
voidsetBasicAuthentication(String user, String password)
Sets Authentication for this client.
voidsetMaxThreads(int maxThreads)
Set the MaxThreads for this Client
voidsetTimeZone(TimeZone z)

Field Detail

asyncWorkers

protected int asyncWorkers

first

private XmlRpcClient.CallData first

last

private XmlRpcClient.CallData last

maxThreads

private int maxThreads
The maximum number of threads which can be used concurrently, by defaut use the one defined in XmlRpc

pool

protected Stack pool

storedPassword

private String storedPassword

storedUser

private String storedUser

transportFactory

protected XmlRpcTransportFactory transportFactory

tz

TimeZone tz

url

protected URL url

workers

protected int workers

Constructor Detail

XmlRpcClient

public XmlRpcClient(URL url, XmlRpcTransportFactory transportFactory)
Construct a XML-RPC client with this URL and a specified transport factory.

XmlRpcClient

public XmlRpcClient(URL url)
Construct a XML-RPC client with this URL.

XmlRpcClient

public XmlRpcClient(String url)
Construct a XML-RPC client for the URL represented by this String.

XmlRpcClient

public XmlRpcClient(String hostname, int port)
Construct a XML-RPC client for the specified hostname and port.

Method Detail

createDefaultTransport

private DefaultXmlRpcTransport createDefaultTransport()

createTransport

protected XmlRpcTransport createTransport()

dequeue

XmlRpcClient.CallData dequeue()

Returns:

enqueue

void enqueue(XmlRpcClient.CallData call)

Parameters: method params callback

execute

public Object execute(String method, Vector params)
Generate an XML-RPC request and send it to the server. Parse the result and return the corresponding Java object.

Throws: XmlRpcException: If the remote host returned a fault message. IOException: If the call could not be made because of lower level problems.

execute

public Object execute(XmlRpcClientRequest request)

execute

public Object execute(XmlRpcClientRequest request, XmlRpcTransport transport)

executeAsync

public void executeAsync(String method, Vector params, AsyncCallback callback)
Generate an XML-RPC request and send it to the server in a new thread. This method returns immediately. If the callback parameter is not null, it will be called later to handle the result or error when the call is finished.

executeAsync

public void executeAsync(XmlRpcClientRequest request, AsyncCallback callback)

executeAsync

public void executeAsync(XmlRpcClientRequest request, AsyncCallback callback, XmlRpcTransport transport)

getMaxThreads

public int getMaxThreads()
Get the MaxThreads for this Client

getTimeZone

public TimeZone getTimeZone()

getURL

public URL getURL()
Return the URL for this XML-RPC client.

getWorker

XmlRpcClientWorker getWorker(boolean async)

Parameters: async

Returns:

Throws: IOException

main

public static void main(String[] args)
Just for testing.

releaseWorker

void releaseWorker(XmlRpcClientWorker w, boolean async)
Release possibly big per-call object references to allow them to be garbage collected

setBasicAuthentication

public void setBasicAuthentication(String user, String password)

Deprecated: Authentication is now handled by each XmlRpcTransport

Sets Authentication for this client. This will be sent as Basic Authentication header to the server as described in http://www.ietf.org/rfc/rfc2617.txt. This method has been deprecated. Furthermore, it has no effect on the overloads for execute and executeAsync that use an XmlRpcClientRequest or an XmlRpcTransport.

See Also: DefaultXmlRpcTransport LiteXmlRpcTransport CommonsXmlRpcTransport

setMaxThreads

public void setMaxThreads(int maxThreads)
Set the MaxThreads for this Client

setTimeZone

public void setTimeZone(TimeZone z)
Copyright B) 1999-2002 Apache Software Foundation. All Rights Reserved.