com.nimkathana.swx.xmlrpc
Class SimpleHttpClient

java.lang.Object
  extended bycom.nimkathana.swx.xmlrpc.SimpleHttpClient

public class SimpleHttpClient
extends java.lang.Object

Provides client-side HTTP communication

Version:
April 2004
Author:
Maintained by Nimkathana (www.nimkathana.com), Original by IOP GmbH (www.iop.de)

Constructor Summary
SimpleHttpClient(java.lang.String hostname, int port, java.lang.String uri)
          Calls initConnection()
 
Method Summary
protected  void closeConnection()
          Terminates the server connection
 java.lang.String execute(byte[] requestBody)
          Executes a HTTP request to the connected server
protected  void finalize()
          Calls closeConnection()
 boolean getKeepAlive()
          Tells if this connection is using a keep alive
protected  void initConnection()
          Called by constructor.
 void setBasicAuthentication(java.lang.String user, java.lang.String password)
          Base64 encodes the username and password given for basic server authentication
 void setKeepAlive(boolean keepAlive)
          Turns keep alive on or off for this connection
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleHttpClient

public SimpleHttpClient(java.lang.String hostname,
                        int port,
                        java.lang.String uri)
                 throws XmlRpcException
Calls initConnection()

Parameters:
hostname - The server address to connect to
port - The port on the server we want to connect to
uri - The connecting URI. Defaults to "/RPC2"
Throws:
XmlRpcException - If the connection to the server could not be made
Method Detail

getKeepAlive

public boolean getKeepAlive()
Tells if this connection is using a keep alive

Returns:
true if a keep alive is being used, false otherwise

setKeepAlive

public void setKeepAlive(boolean keepAlive)
Turns keep alive on or off for this connection

Parameters:
keepAlive - true if a keep alive should be used, false otherwise

setBasicAuthentication

public void setBasicAuthentication(java.lang.String user,
                                   java.lang.String password)
Base64 encodes the username and password given for basic server authentication

Parameters:
user - The username for the server
password - The password for the username account on the server

execute

public java.lang.String execute(byte[] requestBody)
                         throws XmlRpcException
Executes a HTTP request to the connected server

Parameters:
requestBody - The contents of the HTTP request. Headers are added appropriately by this method
Throws:
XmlRpcException - If the server returns a status code other than 200 OK

finalize

protected void finalize()
                 throws java.lang.Throwable
Calls closeConnection()

Throws:
java.lang.Throwable

initConnection

protected void initConnection()
                       throws XmlRpcException
Called by constructor. Makes the actual Socket connection to the server

Throws:
XmlRpcException

closeConnection

protected void closeConnection()
Terminates the server connection



Copyright © 2004 Nimkathana Corp. All Rights Reserved.