org.apache.xmlrpc
Class XmlRpcClient

java.lang.Object
  extended by org.apache.xmlrpc.XmlRpcClient
All Implemented Interfaces:
XmlRpcHandler
Direct Known Subclasses:
SecureXmlRpcClient, XmlRpcClientLite

public class XmlRpcClient
extends java.lang.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.html 359531 2005-12-28 13:59:25Z jochen $
Author:
Hannes Wallnoefer, Andrew Evers, Ryan Hoegg

Nested Class Summary
(package private)  class XmlRpcClient.CallData
           
(package private)  class XmlRpcClient.XmlRpcClientAsyncThread
           
 
Field Summary
protected  int asyncWorkers
           
protected  java.util.Stack pool
           
protected  XmlRpcTransportFactory transportFactory
           
(package private)  java.util.TimeZone tz
           
protected  java.net.URL url
           
protected  int workers
           
 
Constructor Summary
XmlRpcClient(java.lang.String url)
          Construct a XML-RPC client for the URL represented by this String.
XmlRpcClient(java.lang.String hostname, int port)
          Construct a XML-RPC client for the specified hostname and port.
XmlRpcClient(java.net.URL url)
          Construct a XML-RPC client with this URL.
XmlRpcClient(java.net.URL url, XmlRpcTransportFactory transportFactory)
          Construct a XML-RPC client with this URL and a specified transport factory.
 
Method Summary
protected  XmlRpcTransport createTransport()
           
(package private)  XmlRpcClient.CallData dequeue()
           
(package private)  void enqueue(XmlRpcClient.CallData call)
           
 java.lang.Object execute(java.lang.String method, java.util.Vector params)
          Generate an XML-RPC request and send it to the server.
 java.lang.Object execute(XmlRpcClientRequest request)
           
 java.lang.Object execute(XmlRpcClientRequest request, XmlRpcTransport transport)
           
 void executeAsync(java.lang.String method, java.util.Vector params, AsyncCallback callback)
          Generate an XML-RPC request and send it to the server in a new thread.
 void executeAsync(XmlRpcClientRequest request, AsyncCallback callback)
           
 void executeAsync(XmlRpcClientRequest request, AsyncCallback callback, XmlRpcTransport transport)
           
 int getMaxThreads()
          Get the MaxThreads for this Client
 java.util.TimeZone getTimeZone()
           
 java.net.URL getURL()
          Return the URL for this XML-RPC client.
(package private)  XmlRpcClientWorker getWorker(boolean async)
           
static void main(java.lang.String[] args)
          Just for testing.
(package private)  void releaseWorker(XmlRpcClientWorker w, boolean async)
          Release possibly big per-call object references to allow them to be garbage collected
 void setBasicAuthentication(java.lang.String user, java.lang.String password)
          Deprecated. Authentication is now handled by each XmlRpcTransport
 void setMaxThreads(int maxThreads)
          Set the MaxThreads for this Client
 void setTimeZone(java.util.TimeZone z)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

url

protected java.net.URL url

pool

protected java.util.Stack pool

workers

protected int workers

asyncWorkers

protected int asyncWorkers

transportFactory

protected XmlRpcTransportFactory transportFactory

tz

java.util.TimeZone tz
Constructor Detail

XmlRpcClient

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


XmlRpcClient

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


XmlRpcClient

public XmlRpcClient(java.lang.String url)
             throws java.net.MalformedURLException
Construct a XML-RPC client for the URL represented by this String.

Throws:
java.net.MalformedURLException

XmlRpcClient

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

Throws:
java.net.MalformedURLException
Method Detail

setMaxThreads

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


getMaxThreads

public int getMaxThreads()
Get the MaxThreads for this Client


getURL

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


setBasicAuthentication

public void setBasicAuthentication(java.lang.String user,
                                   java.lang.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

execute

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

Specified by:
execute in interface XmlRpcHandler
Throws:
XmlRpcException: - If the remote host returned a fault message.
IOException: - If the call could not be made because of lower level problems.
XmlRpcException
java.io.IOException

execute

public java.lang.Object execute(XmlRpcClientRequest request)
                         throws XmlRpcException,
                                java.io.IOException
Throws:
XmlRpcException
java.io.IOException

execute

public java.lang.Object execute(XmlRpcClientRequest request,
                                XmlRpcTransport transport)
                         throws XmlRpcException,
                                java.io.IOException
Throws:
XmlRpcException
java.io.IOException

executeAsync

public void executeAsync(java.lang.String method,
                         java.util.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)

getWorker

XmlRpcClientWorker getWorker(boolean async)
                       throws java.io.IOException
Parameters:
async -
Returns:
Throws:
java.io.IOException

setTimeZone

public void setTimeZone(java.util.TimeZone z)

getTimeZone

public java.util.TimeZone getTimeZone()

releaseWorker

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


enqueue

void enqueue(XmlRpcClient.CallData call)
Parameters:
method -
params -
callback -

dequeue

XmlRpcClient.CallData dequeue()
Returns:

createTransport

protected XmlRpcTransport createTransport()
                                   throws XmlRpcClientException
Throws:
XmlRpcClientException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Just for testing.

Throws:
java.lang.Exception


Copyright 2001-2001-2005 Apache Software Foundation. All Rights Reserved.