You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Robert Thullner <rt...@gmx.at> on 2008/01/03 21:16:37 UTC

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
 
 

Re: Invoke HTTP Provider Endpoint

Posted by Robert Thullner <rt...@gmx.at>.
Thank you for your reply. I think I somehow explained my problem wrong. 
This is my situation: I have a REST service hosted somewhere. What I want is
that servicemix calls this service and passes back the reply. My client
shall never call the REST service, this shall be done by servicemix. So my
message flow should be somehow like that

client -> initiator -> smx-http-provider -> resultreceiver -> client

I was thinking about a client that sends a JMS message to the initiator. My
problem now is, that I do not know which SUs the initiator and the
resultreceiver should be? Are the initiator and resultreceiver the same SU?
Or even if the smx-http-provider is the correct SU for calling my service?
Do you have any example where servicemix calls a webservice not hosted in
servicemix and passes back the result? I did not find any like that?

Thanks, 
Robert



bsnyder wrote:
> 
> 
> Based on what you have described, you can achieve this by using two
> SUs, one to configure the servicemix-http component and the one to
> configure the servicemix-bean component. The servicemix-bean component
> (http://servicemix.apache.org/servicemix-bean.html) can be used to
> expose POJOs internally in ServiceMix. Then the servicemix-http
> component (http://servicemix.apache.org/servicemix-http.html) to
> expose the POJO service externally to ServiceMix. The component flow
> would look like this:
> 
> client --> smx-http --> smx-bean
> 
> The client sends a request in the form of a XML message to a HTTP URL
> hosted by the servicemix-http component which sends the message along
> to the POJO service that is running in the servicemix-bean component.
> The default message exchange pattern (MEP) for the servicemix-http
> component is in-out so the response from the POJO serviced hosted in
> the servicemix-bean component will come right back through the
> servicemix-http component to the client who initiated the request.
> 
> If you haven't done so already, I *highly* advise walking through the
> first two tutorials here:
> 
> http://servicemix.apache.org/tutorials.html
> 
> This will help you get a basic understanding of things.
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> Apache Geronimo - http://geronimo.apache.org/
> 
> Blog: http://bruceblog.org/
> 
> 

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


MEP confusion / Providers / Consumers

Posted by ma...@uk.bnpparibas.com.
hi alll,
 i am going thru docs for MEP here 
http://servicemix.apache.org/5-jbi.html#5.JBI-ServiceinvocationandMEP
but  i am still a little confused./...

here's my plan for my application

BC1(listens to MQ) which calls SE1 which calls SE2

messages are in one direction only, but i'd like to provide some fault 
tolerance....  therefore
i was wondering of using  Robust-In-Only as an interaction between 
components....

However, i m puzzled about roles of consumer/producers....

as far as my undestanding goes,:

BC1 looks like  a consumer, as it consumes messages from MQ
SE1 would be  a provider, as BC1 requires his services. 
But then, SE2 is a provider too as SE1 requires his services.....

is my understanding correct?

thanks and regards
        marco



This communication is confidential, may be privileged and is meant only for the intended recipient.  If you are 
not the intended recipient, please notify the sender by reply and delete this message from your system.  Any 
unauthorised dissemination, distribution or copying hereof is prohibited.

BNP Paribas Fund Services UK Limited, BNP Paribas Trust Corporation UK Limited, BNP Paribas UK Limited, 
BNP Paribas Commodity Futures Ltd and Investment Fund Services Limited are authorised and regulated by 
the Financial Services Authority.

BNP Paribas, BNP Paribas Securities Services and BNP Paribas Private Bank are authorised by the CECEI 
and AMF.  BNP Paribas London Branch, BNP Paribas Securities Services London Branch and BNP Paribas 
Private Bank London Branch are regulated by the Financial Services Authority for the conduct of their UK 
business.  BNP Paribas Securities Services London Branch is also a member of the London Stock Exchange.


Re: Invoke HTTP Provider Endpoint

Posted by Bruce Snyder <br...@gmail.com>.
On Jan 3, 2008 1:16 PM, Robert Thullner <rt...@gmx.at> wrote:
> 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?

Based on what you have described, you can achieve this by using two
SUs, one to configure the servicemix-http component and the one to
configure the servicemix-bean component. The servicemix-bean component
(http://servicemix.apache.org/servicemix-bean.html) can be used to
expose POJOs internally in ServiceMix. Then the servicemix-http
component (http://servicemix.apache.org/servicemix-http.html) to
expose the POJO service externally to ServiceMix. The component flow
would look like this:

client --> smx-http --> smx-bean

The client sends a request in the form of a XML message to a HTTP URL
hosted by the servicemix-http component which sends the message along
to the POJO service that is running in the servicemix-bean component.
The default message exchange pattern (MEP) for the servicemix-http
component is in-out so the response from the POJO serviced hosted in
the servicemix-bean component will come right back through the
servicemix-http component to the client who initiated the request.

If you haven't done so already, I *highly* advise walking through the
first two tutorials here:

http://servicemix.apache.org/tutorials.html

This will help you get a basic understanding of things.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/

Blog: http://bruceblog.org/

Re: AW: Invoke HTTP Provider Endpoint

Posted by Tom Purcell <tp...@chariotsolutions.com>.
 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.


AW: Invoke HTTP Provider Endpoint

Posted by Robert Thullner <rt...@gmx.at>.
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