Dear all,
I have some problem getting XML-RPC 3.0b1 to work.
The last years I was always working with version 1 and later on version
2, but now I was somewhat attracted by the nice new features of version
3.
I tried to set up a very simple client server from which you can see the
code here:
Server:
#########################################################
static int port = 3099;
private WebServer server;
public static void main(String[] args) {
new Start();
}
public Start(){
try {
server = new WebServer(port);
XmlRpcServerConfigImpl config = new
XmlRpcServerConfigImpl();
config.setEnabledForExtensions(true);
config.setContentLengthOptional(true);
server.getXmlRpcServer().setConfig(config);
server.start();
System.out.println("RPC server
running.");
}
catch (Exception e) {
e.printStackTrace();
}
}
public int loginUser(String userId ) {
return 0;
}
#########################################################
Client:
#########################################################
static XmlRpcClient xmlrpc;
public static void main( String args[] ) {
try {
Vector params = new Vector ();
params.addElement( "user1" );
XmlRpcClientConfigImpl config = new
XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://localhost:3099/"));
config.setEnabledForExtensions(true);
config.setContentLengthOptional(true);
xmlrpc = new XmlRpcClient();
xmlrpc.setConfig(config);
Integer r = (Integer) xmlrpc.execute ("loginUser", params);
} catch (Exception e) {
e.printStackTrace( System.out );
}
}
#########################################################
If I now start the server and fire the client I get the following
exceptions:
Server:
#########################################################
18-jul-2006 11:19:52 org.apache.xmlrpc.server.XmlRpcStreamServer execute
SEVERE: execute: Error while performing request
java.lang.NullPointerException
at
org.apache.xmlrpc.server.XmlRpcServerWorker.execute(XmlRpcServerWorker.j
ava:42)
at
org.apache.xmlrpc.server.XmlRpcServer.execute(XmlRpcServer.java:79)
at
org.apache.xmlrpc.server.XmlRpcStreamServer.execute(XmlRpcStreamServer.j
ava:182)
at org.apache.xmlrpc.webserver.Connection.run(Connection.java:175)
at
org.apache.xmlrpc.util.ThreadPool$MyThread.runTask(ThreadPool.java:71)
at
org.apache.xmlrpc.util.ThreadPool$MyThread.run(ThreadPool.java:87)
#########################################################
Client:
#########################################################
org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse servers
response: The XML declaration may only appear at the very beginning of
the document.
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStream
Transport.java:174)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamT
ransport.java:149)
at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTrans
port.java:95)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHtt
pTransport.java:39)
at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.j
ava:53)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:157)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:146)
at
nl.tue.bluis.client.application.userDetectionClient.XmlRpcTest.main(XmlR
pcTest.java:42)
Caused by:
org.xml.sax.SAXParseException: The XML declaration may only appear at
the very beginning of the document.
at
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213)
at
org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDo
cumentScanner.java:570)
at
org.apache.xerces.framework.XMLDocumentScanner.abortMarkup(XMLDocumentSc
anner.java:624)
at
org.apache.xerces.framework.XMLDocumentScanner$PrologDispatcher.dispatch
(XMLDocumentScanner.java:810)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScan
ner.java:381)
at
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStream
Transport.java:172)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamT
ransport.java:149)
at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTrans
port.java:95)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHtt
pTransport.java:39)
at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.j
ava:53)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:157)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:146)
at
nl.tue.bluis.client.application.userDetectionClient.XmlRpcTest.main(XmlR
pcTest.java:42)
#########################################################
I don't really get why I get these exceptions.
Online I couldn't really find any link which explains a similar problem,
or describes the same setting.
I hope anybody here can give me some pointers about what goes wrong.
With kind regards,
Pieter
|