<bean id="fooService"
class="com.agelion.server.impl.DummyService">
<bean name="/FooService"
class="org.springframework.remoting.caucho.BurlapServiceExporter">
<property name="service" ref="fooService"/>
<property name="serviceInterface"
value="com.agelion.server.FooBackendService"/>
</bean>
. Thats it for the Java side. Burlap is a very simple protocol where you dont map classes, what you get is a map with key, value pairs. But thats fine for me.
But also the Ruby side is easy to implement. I am still a newby with Ruby but that was relativly quick done (though its still not as easy to get information like you get for J2EE for instance, where you get too much information).
Because the Burlap protocol just supports the POST method you need the low level Ruby methods for Http:
Net::HTTP.start('localhost', 8080) do |request|
response = request.post('/backendservice/FooService',
'<burlap:call><method>myMethod</method></burlap:call>')
And here we go. All you have to do is to parse this XML:
vals = []
XPath.each( Document.new(response.body),
"//burlap:reply/list/map/*")
{|p| vals << p.text }
And as I said, what you get are key-value pairs with the exception of the first element which descripes the original type (classname).
I converted it to a map skipping the first element in the array:
@bashvals = {}
1.step(vals.length-1, 2)
{ |i| @bashvals[vals[i]] = vals[i+1] }
Keine Kommentare:
Kommentar veröffentlichen