You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Tom Purcell <tp...@chariotsolutions.com> on 2008/03/06 15:53:22 UTC

Re: AW: Invoke HTTP Provider Endpoint

 Robert

I'm working on a similar use case. If all you want to do is have ServiceMix
route a message that comes in on a JMS queue to the RESTful service and have
the response go back to the original caller than all you need are two
binding component service units: one for JMS(servicemix-jms) and one for
HTTP(servicemix-http). Your xbean config would look like this:

For JMS
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:test="http://test"
       xmlns:amq="http://activemq.org/config/1.0">

    <jms:endpoint service="test:MyJmsQueueToRestTest"
                  endpoint="jmsToRestQueue"
                  targetService="test:myHttpProviderRestService"
                  targetEndpoint="myHttpProviderRest"
                  role="consumer"
                  destinationStyle="queue"
                  jmsProviderDestinationName="myJmsQueueToRestTest"
                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                  connectionFactory="#connectionFactory"></jms:endpoint>
    <!-- END SNIPPET: consumer -->

    <amq:connectionFactory id="connectionFactory"
brokerURL="tcp://localhost:61616" />
</beans>

For HTTP
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
       xmlns:test="http://test">

  <http:endpoint service="test:myHttpProviderRestService"
                 endpoint="myHttpProviderRest"
                 role="provider"
                
locationURI="http://localhost:8380/HumidityRestService-1.0.0/humidity"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 soap="false" />             
</beans>

Of course your JMS client would have to set a replyTo queue on its outgoing
message.

The above assumes you just want to pass the message along and do not need to
do any processing in the interim. If you do need to process the message in
some way how you do it depends on what you need to do but one of the EIP
patterns implemented by servicemix-eip or servicemix-camel may help.


Tom

 

Robert Thullner wrote:
> 
> I still did not get any further with this problem
> 
> Are there any hints how I could solve this?
> 
> Thanks
> Robert 
> 
> -----Ursprüngliche Nachricht-----
> Von: Robert Thullner [mailto:rthullner@gmx.at] 
> Gesendet: Donnerstag, 03. Jänner 2008 21:17
> An: users@servicemix.apache.org
> Betreff: Invoke HTTP Provider Endpoint
> 
> Hi 
>  
> I have an external REST service, that I want to make available through
> ServiceMix. For the service I have build a HTTP Provider SU, which looks
> like this:
>  
> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>     xmlns:weather="http://servicemix.apache.org/weatherServiceMix">
>  
> <http:endpoint service="weather:restService"
>    endpoint="restEndpoint"
>    role="provider" 
>    locationURI="http://localhost:8380/HumidityRestService-1.0.0/humidity"
>    defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>    soap="false" />             
> </beans>
>  
> The REST service returns a String that shall be passed back to the caller.
> But this is where I got stuck. How can I write a SU that can send request
> to
> my weather:restService and pass back the replies? 
> I was thinking about some ways to achieve that. First I thought about a
> quartz that invokes my service in a given interval but I do not know how
> and
> where the result of the REST service can be passed to some other SU that
> can
> put it on e.g. a JMS queue. 
> I was also thinking that I use a JMS consumer that can receive message
> from
> a client outside ServiceMix and then calls my weather:restService but
> again
> I did not know how the result can be passed back to the Client who
> initially
> send a JMS message. 
> I further looked at the beans components but could not find any example
> where a beans initiates a MessageExchange, all examples only show the
> onMessageExchange() method, which is invoked when a message is received. 
>  
> Do you have any suggestions for me how I can make the REST service
> available
> through ServiceMix to clients outside ServiceMix. It should be some kind
> of
> bridge component at the, perhaps like the bridge example, but the other
> way
> round. 
>  
> Are there any examples how a HTTP provider endpoint can be invoked within
> ServiceMix? I did not find any for that?
>  
> Thanks
> Robert
>  
>  
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Invoke-HTTP-Provider-Endpoint-tp14604574s12049p15873171.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.