public class XMLRPCClient extends Object
Modifier and Type | Field and Description |
---|---|
static int |
FLAGS_8BYTE_INT
The client will be able to handle 8 byte integer values (longs).
|
static int |
FLAGS_APACHE_WS
This flag should be used if the server is an apache ws xmlrpc server.
|
static int |
FLAGS_DEBUG
Activate debug mode.
|
static int |
FLAGS_DEFAULT_TYPE_STRING
With this flag enabled, a value with a missing type tag, will be parsed
as a string element.
|
static int |
FLAGS_ENABLE_COOKIES
With this flag, the client will be able to handle cookies, meaning saving cookies
from the server and sending it with every other request again.
|
static int |
FLAGS_FORWARD
With this flag enabled, the client will forward the request, if
the 301 or 302 HTTP status code has been received.
|
static int |
FLAGS_IGNORE_NAMESPACES
With this flag enabled, the
XMLRPCClient ignores all namespaces
used within the response from the server. |
static int |
FLAGS_IGNORE_STATUSCODE
With this flag enabled, the XML-RPC client will ignore the HTTP status
code of the response from the server.
|
static int |
FLAGS_NIL
The client will be able to send null values.
|
static int |
FLAGS_NO_STRING_DECODE
This prevents the decoding of incoming strings, meaning & and <
won't be decoded to the & sign and the "less then" sign.
|
static int |
FLAGS_NO_STRING_ENCODE
By default outgoing string values will be encoded according to specification.
|
static int |
FLAGS_NONE
No flags should be set.
|
static int |
FLAGS_SSL_IGNORE_ERRORS
This flag disables all SSL warnings.
|
static int |
FLAGS_SSL_IGNORE_INVALID_CERT
With this flag enabled, the client will ignore all unverified SSL/TLS
certificates.
|
static int |
FLAGS_SSL_IGNORE_INVALID_HOST
With this flag enabled, the client will ignore, if the URL doesn't match
the SSL Certificate.
|
static int |
FLAGS_STRICT
The client should parse responses strict to specification.
|
static int |
FLAGS_USE_SYSTEM_PROXY
With this flag enabled, the
XMLRPCClient will use the system http
proxy to connect to the XML-RPC server. |
static String |
VALUE |
Constructor and Description |
---|
XMLRPCClient(URL url)
Create a new XMLRPC client for the given url.
|
XMLRPCClient(URL url,
int flags)
Create a new XMLRPC client for the given URL.
|
XMLRPCClient(URL url,
String userAgent)
Create a new XMLRPC client for the given url.
|
XMLRPCClient(URL url,
String userAgent,
int flags)
Create a new XMLRPC client for the given URL.
|
Modifier and Type | Method and Description |
---|---|
Object |
call(String method,
Object... params)
Call a remote procedure on the server.
|
long |
callAsync(XMLRPCCallback listener,
String methodName,
Object... params)
Asynchronously call a remote procedure on the server.
|
void |
cancel(long id)
Cancel a specific asynchronous call.
|
void |
clearCookies()
Delete all cookies currently used by the client.
|
void |
clearLoginData()
Clear the username and password.
|
Map<String,String> |
getCookies()
Returns a
Map of all cookies. |
URL |
getURL()
Returns the URL this XMLRPCClient is connected to.
|
void |
installCustomKeyManager(KeyManager keyManager)
Installs a custom
KeyManager to handle SSL/TLS certificate verification. |
void |
installCustomKeyManagers(KeyManager[] keyManagers)
Installs custom
KeyManagers to handle SSL/TLS certificate
verification. |
void |
installCustomTrustManager(TrustManager trustManager)
Installs a custom
TrustManager to handle SSL/TLS certificate verification. |
void |
installCustomTrustManagers(TrustManager[] trustManagers)
Installs custom
TrustManagers to handle SSL/TLS certificate
verification. |
void |
setCustomHttpHeader(String headerName,
String headerValue)
Set a HTTP header field to a custom value.
|
void |
setLoginData(String user,
String pass)
Set the username and password that should be used to perform basic
http authentication.
|
void |
setProxy(Proxy proxy)
Sets a proxy to use for this client.
|
void |
setTimeout(int timeout)
Sets the time in seconds after which a call should timeout.
|
void |
setUserAgentString(String userAgent)
Sets the user agent string.
|
public static final String VALUE
public static final int FLAGS_NONE
public static final int FLAGS_STRICT
public static final int FLAGS_8BYTE_INT
public static final int FLAGS_ENABLE_COOKIES
public static final int FLAGS_NIL
public static final int FLAGS_IGNORE_STATUSCODE
public static final int FLAGS_FORWARD
public static final int FLAGS_SSL_IGNORE_INVALID_HOST
public static final int FLAGS_SSL_IGNORE_INVALID_CERT
installCustomTrustManager(javax.net.ssl.TrustManager)
won't have any effect.public static final int FLAGS_DEFAULT_TYPE_STRING
public static final int FLAGS_IGNORE_NAMESPACES
XMLRPCClient
ignores all namespaces
used within the response from the server.public static final int FLAGS_USE_SYSTEM_PROXY
XMLRPCClient
will use the system http
proxy to connect to the XML-RPC server.public static final int FLAGS_NO_STRING_DECODE
FLAGS_NO_STRING_ENCODE
for the counterpart.public static final int FLAGS_NO_STRING_ENCODE
FLAGS_NO_STRING_ENCODE
for the counterpart.public static final int FLAGS_DEBUG
public static final int FLAGS_SSL_IGNORE_ERRORS
public static final int FLAGS_APACHE_WS
public XMLRPCClient(URL url, String userAgent, int flags)
url
- The URL to send the requests to.userAgent
- A user agent string to use in the HTTP requests.flags
- A combination of flags to be set.public XMLRPCClient(URL url, int flags)
url
- The URL to send the requests to.flags
- A combination of flags to be set.public XMLRPCClient(URL url, String userAgent)
url
- The url to send the requests to.userAgent
- A user agent string to use in the http request.public XMLRPCClient(URL url)
url
- The url to send the requests to.public URL getURL()
public void setTimeout(int timeout)
timeout
will be zero or less the connection will never timeout.
In case the connection times out an XMLRPCTimeoutException
will
be thrown for calls made by call(java.lang.String, java.lang.Object[])
.
For calls made by callAsync(de.timroes.axmlrpc.XMLRPCCallback, java.lang.String, java.lang.Object[])
the XMLRPCCallback.onError(long, de.timroes.axmlrpc.XMLRPCException)
method
of the callback will be called. By default connections won't timeout.timeout
- The timeout for connections in seconds.public void setUserAgentString(String userAgent)
userAgent
- The new user agent string.public void setProxy(Proxy proxy)
FLAGS_USE_SYSTEM_PROXY
instead. If combined with
FLAGS_USE_SYSTEM_PROXY
, this proxy will be used instead of the
system proxy.proxy
- A proxy to use for the connection.public void setCustomHttpHeader(String headerName, String headerValue)
headerName
- The name of the header field.headerValue
- The new value of the header field.public void setLoginData(String user, String pass)
user
- Usernamepass
- Passwordpublic void clearLoginData()
public Map<String,String> getCookies()
Map
of all cookies. It contains each cookie key as a map
key and its value as a map value. Cookies will only be used if FLAGS_ENABLE_COOKIES
has been set for the client. This map will also be available (and empty)
when this flag hasn't been said, but has no effect on the HTTP connection.Map
of all cookies.public void clearCookies()
public void installCustomTrustManager(TrustManager trustManager)
TrustManager
to handle SSL/TLS certificate verification.
This will replace any previously installed TrustManager
s.
If FLAGS_SSL_IGNORE_INVALID_CERT
is set, this won't do anything.trustManager
- TrustManager
to install.installCustomTrustManagers(javax.net.ssl.TrustManager[])
public void installCustomTrustManagers(TrustManager[] trustManagers)
TrustManagers
to handle SSL/TLS certificate
verification. This will replace any previously installed TrustManagers
s.
If FLAGS_SSL_IGNORE_INVALID_CERT
is set, this won't do anything.trustManagers
- TrustManagers
to install.installCustomTrustManager(javax.net.ssl.TrustManager)
public void installCustomKeyManager(KeyManager keyManager)
KeyManager
to handle SSL/TLS certificate verification.
This will replace any previously installed KeyManager
s.
If FLAGS_SSL_IGNORE_INVALID_CERT
is set, this won't do anything.keyManager
- KeyManager
to install.installCustomKeyManagers(javax.net.ssl.KeyManager[])
public void installCustomKeyManagers(KeyManager[] keyManagers)
KeyManagers
to handle SSL/TLS certificate
verification. This will replace any previously installed KeyManagers
s.
If FLAGS_SSL_IGNORE_INVALID_CERT
is set, this won't do anything.keyManagers
- KeyManagers
to install.installCustomKeyManager(javax.net.ssl.KeyManager)
public Object call(String method, Object... params) throws XMLRPCException
method
- A method name to call.params
- An array of parameters for the method.XMLRPCException
- Will be thrown if an error occurred during the call.public long callAsync(XMLRPCCallback listener, String methodName, Object... params)
listener
- A listener, which will be notified about the server response or errors.methodName
- A method name to call on the server.params
- An array of parameters for the method.public void cancel(long id)
id
- The id of the call as returned by the callAsync method.Copyright © 2016. All rights reserved.