You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Eric Shea <es...@optaros.com> on 2008/01/24 14:35:09 UTC

ServiceMix REST calls

Hi, 

I'm trying to get a simple example of calling and exposing a simple REST service from ServiceMix. I went through the archives but wasn't able to get any of the examples working. 

What I'm shooting for is to have an http consumer exposing some service "http://0.0.0.0:8192/client" which would take in Post/Get parameters and then bridge over to REST providers (serviceA, serviceB, etc) based upon content. 

Currently I have a simple eip router which chooses service A or B based on an XPath expression and then two services which respond back to the router with a message indicating the other service. Thus an initial message containing "<serviceA>" should hit service A which should then respond with "<serviceB>" and get routed to that service. 

I've found that the router works but that the response from either service does not generate or alter the message and the chain follows: 
Router - > Service A - > Router -> Done 

I've also tried using HttpConnector and HttpInvoker without success. Any ideas are appreciated! 

Here is my config: 
router-su 
<eip:content-based-router service="my:router" endpoint="endpoint"> 
<eip:rules> 
<eip:routing-rule> 
<eip:predicate> 
<eip:xpath-predicate xpath="count(*/serviceA) = 1"/> 
</eip:predicate> 
<eip:target> 
<eip:exchange-target service="my:serviceA" /> 
</eip:target> 
</eip:routing-rule> 
<eip:routing-rule> 
<eip:predicate> 
<eip:xpath-predicate xpath="count(*/serviceB) = 1"/> 
</eip:predicate> 
<eip:target> 
<eip:exchange-target service="my:serviceB" /> 
</eip:target> 
</eip:routing-rule> 
<eip:routing-rule> 
<!-- there is no predicate, so this is the default destination --> 
<eip:target> 
<eip:exchange-target service="my:defaultService" /> 
</eip:target> 
</eip:routing-rule> 
</eip:rules> 
</eip:content-based-router> 

http-su 
<http:endpoint service="my:serviceA" 
endpoint="serviceA" 
role="provider" 
targetService="my:router" 
locationURI="http://localhost/serviceA?test=true" 
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"> 
</http:endpoint> 

<http:endpoint service="my:serviceB" 
endpoint="serviceB" 
role="provider" 
targetService="my:router" 
locationURI="http://localhost/serviceB?test=true" 
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"> 
</http:endpoint> 

and my try at HttpInvoker: 
bean-su 
<bean:endpoint service="my:serviceC" endpoint="serviceC" bean="#serviceBean"/> 

<bean id="serviceBean" 
service="my:serviceC" 
class="org.apache.servicemix.components.http.HttpInvoker" 
destinationService="my:router" 
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"> 
<property name="url" value="http://localhost/serviceC?test=true"/> 
</bean> 


Thanks! 
Eric