ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bellekens, P.A.E." <P.A.E.Bellek...@TUE.nl>
Subject RE: XML-RPC embedded in Jetty
Date Wed, 23 Aug 2006 15:08:15 GMT
>> The ServerStreamConnection is a class which can make an inputstream
from
>> a certain socket or httpservletrequest object. But I already have an
>> inputstream (containing the raw httprequest) so I have no means to
>> instantiate this class...

>Take the XmlRpcLocalStreamServer and the LocalStreamConnection as an 
>example: A raw InputStream is fine. (That's what the XmlRpcStreamServer

>is made for.)


Hi Jochen,

I have been experimenting with these two classes inside Jetty, but now I
seem to be a bit stuck. Let me show some code:

---------------------------------------------------------------------
// First initialize the server
XmlRpcServerConfigImpl serverConfig = new XmlRpcServerConfigImpl();
serverConfig.setEnabledForExtensions(true);
serverConfig.setKeepAliveEnabled(true);
				
PropertyHandlerMapping dhm = new PropertyHandlerMapping();
				
try {
	dhm.addHandler("Ums", MethodForwarder.class);
} catch (XmlRpcException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
				
XmlRpcLocalStreamServer server = new XmlRpcLocalStreamServer();
server.setConfig(serverConfig);
server.setHandlerMapping(dhm);
---------------------------------------------------------------------

I guess so far so good. Now initialize the client with the inputstream I
get from Jetty:

---------------------------------------------------------------------
// initialize client
XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl();
clientConfig.setEnabledForExtensions(true);
clientConfig.setContentLengthOptional(true);
				
LocalStreamConnection lsc = new LocalStreamConnection(clientConfig, new
LimitedInputStream(getInputStream(), getInputStream().available()));
---------------------------------------------------------------------


Now I want to execute the client request at the server:

---------------------------------------------------------------------
try {
	server.execute(clientConfig, lsc.getServerStreamConnection());
} catch (XmlRpcException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
System.out.println("Answer: "+lsc.getResponse().toString());
---------------------------------------------------------------------


When I execute this I get an exception:

java.lang.NullPointerException
        at
org.apache.xmlrpc.server.XmlRpcLocalStreamServer.execute(XmlRpcLocalStre
amServer.java:14)
        at
org.apache.xmlrpc.server.XmlRpcStreamServer.execute(XmlRpcStreamServer.j
ava:182)
        at
nl.tue.bluis.systemservices.usermodelservice.UmsXmlRpcHandler.handle(Ums
XmlRpcHandler.java:146)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
        at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
        at org.mortbay.http.HttpServer.service(HttpServer.java:909)
        at
org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
        at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
        at
org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
        at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244
)
        at
org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
        at
org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
execute goed gegaan

Answer: <?xml version="1.0" encoding="UTF-8"?><methodResponse
xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions"><fault><val
ue><struct><member><name>faultString</name><value></value></member><memb
er><name>faultCode</name><value><i4>0</i4></value></member></struct></va
lue></fault></methodResponse>


After looking a bit in the code I found that this nullpointer was thrown
because the 

setXmlRpcServer(XmlRpcRequestProcessor pServer) 

property was not set in the XmlRpcClientConfigImpl object. So I added
the following line to the client config:

clientConfig.setXmlRpcServer(server);

setting the server as the xmlrpcserver of the client. However, when I
added this line I got a non stopping throwing of the following
exception:

java.lang.StackOverflowError
        at
org.apache.xmlrpc.server.XmlRpcLocalStreamServer.execute(XmlRpcLocalStre
amServer.java:14)
org.apache.xmlrpc.server.XmlRpcLocalStreamServer.execute(XmlRpcLocalStre
amServer.java:14)
org.apache.xmlrpc.server.XmlRpcLocalStreamServer.execute(XmlRpcLocalStre
amServer.java:14)
	....

It appears like a loop which constantly throws this error.
Any ideas of what I am doing wrong?

Regards
p.


-----Original Message-----
From: Jochen Wiedmann [mailto:jochen.wiedmann@gmail.com] 
Sent: woensdag 23 augustus 2006 12:46
To: xmlrpc-user@ws.apache.org
Subject: Re: XML-RPC embedded in Jetty

Bellekens, P.A.E. wrote:

> The ServerStreamConnection is a class which can make an inputstream
from
> a certain socket or httpservletrequest object. But I already have an
> inputstream (containing the raw httprequest) so I have no means to
> instantiate this class...

Take the XmlRpcLocalStreamServer and the LocalStreamConnection as an 
example: A raw InputStream is fine. (That's what the XmlRpcStreamServer 
is made for.)


Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-user-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-user-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-user-help@ws.apache.org


Mime
View raw message