You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Geert Schuring <ge...@schuring.eu> on 2010/04/23 12:27:06 UTC

Advise needed: Compontent for receiving HTTP requests

Hey all,

I need some advice about the following:

We're using an SMS Gateway service that sends received SMS messages to our
system using HTTP POST requests with the message and sender in the request
parameters.
Initially I though it wouldn't be a problem to receive these messages
using the servicemix-http component, but as it turns out this component
can only create some sort of proxy for other JBI endpoints.

What I need is a BC that I can configure to listen at a certain URL and
that sends a message to the NMR for every HTTP request that is received on
this URL. I can then use standard servicemix components to transform the
message and send it to our processing server.

As far as I can see (I'm new to servicemix, just started researching it a
week ago) I need to create a custom BC to realize this scenario.

What do you think about this?

Geert.


Re: Advise needed: Compontent for receiving HTTP requests

Posted by iocanel <ca...@upstreamsystems.com>.

Geert Schuring wrote:
> 
> Could you show me how you configured the endpoint because I keep having 
> trouble with it.
> Also, where do I get the 'new' http endpoint?
> 

The documentation of the new http endpoints is here:
http://servicemix.apache.org/servicemix-http-new-endpoints.html New
ServiceMix HTTP Endpoints .

Here is how I am using the Http Consumer Endpoint:

<!-- This endpoint is responsible for receiving http requests and sending
normalized messages in the bus -->
<http:consumer service="sns:http-consumer"
               endpoint="httpEndpoint"
               targetService="sns:message-processor" <!-- The service that
will process the messages, this could be a jms provider that puts messages
in a queue -->
               marshaler="#myMarshaler" <!-- I am telling the endpoint here
which spring bean will play the role of the marshaler -->
               locationURI="http://0.0.0.0:8181/message/" /> 

<!-- The bean definition of my marshaler -->
<!-- The marshaler is responsible for transforming the Http request to
normalized message -->
<bean id="myMarshaler" class="net.iocanel.marshaler.MyMarshaler"/>

And finally here is a snapshot of the marshaler itself.
This is an example marshaler that will read requests like this
http://0.0.0.0:8181/message/msg?type=1&dest=1000&sender=55112456&msg=Hi+Gert
and will create exchange out of it.

package net.iocanel.marshaler;

public class MyMarshaler extends DefaultHttpConsumerMarshaler {

public MessageExchange createExchange(HttpServletRequest request,
ComponentContext context) throws Exception {
        String type = request.getParameter("type");
        String dest = request.getParameter("dest");
        String sender = request.getParameter("sender");
        String message = request.getParameter("msg");

        MessageExchange exchange = ((EndpointComponentContext)
context).getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());
        NormalizedMessage in = exchange.createMessage();
        
        String xmlContext = requestParams2XML(type,dest,sender,message);
//This is an imaginary method that creates a String containing the xml that
will be the payload of your exchange.
        in.setContent(new StringSource(xmlContext));
        exchange.setMessage(in,"in");
        return exchange;
}


In order to be able to fully understand it maybe you have to take it step by
step, see the examples like wsdl-first and then start playing with it.

I hope this helped.


-----
Ioannis Canellos
-- 
View this message in context: http://old.nabble.com/Advise-needed%3A-Compontent-for-receiving-HTTP-requests-tp28339683p28361936.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Advise needed: Compontent for receiving HTTP requests

Posted by Geert Schuring <ge...@schuring.eu>.
Ioannis,

Could you show me how you configured the endpoint because I keep having 
trouble with it.
Also, where do I get the 'new' http endpoint?

Geert.

--------------------------------------------------
From: "iocanel" <ca...@upstreamsystems.com>
Sent: Friday, April 23, 2010 5:54 PM
To: <us...@servicemix.apache.org>
Subject: Re: Advise needed: Compontent for receiving HTTP requests

>
> Hi Geert,
>
> You don't need to create a custom BC for the purpose.
>
> You can use either http endpoint or the new http consumer endpoint (I 
> prefer
> the new endpoint).
>
> You can configure the http consumer to listen to the uri of your likes and
> it will create a message exchange for every request it receives. The 
> format
> of the payload of your exchange can be customized by providing the 
> endpoint
> with a custom marshaler.
>
> I've been using servicemix-http for the same purpose (sms exchange) for 
> the
> last year and I am pretty happy with it.
>
>
> -----
> Ioannis Canellos
> -- 
> View this message in context: 
> http://old.nabble.com/Advise-needed%3A-Compontent-for-receiving-HTTP-requests-tp28339683p28343204.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
>
> 

Re: Advise needed: Compontent for receiving HTTP requests

Posted by iocanel <ca...@upstreamsystems.com>.
Hi Geert,

You don't need to create a custom BC for the purpose.

You can use either http endpoint or the new http consumer endpoint (I prefer
the new endpoint). 

You can configure the http consumer to listen to the uri of your likes and
it will create a message exchange for every request it receives. The format
of the payload of your exchange can be customized by providing the endpoint
with a custom marshaler.

I've been using servicemix-http for the same purpose (sms exchange) for the
last year and I am pretty happy with it.


-----
Ioannis Canellos
-- 
View this message in context: http://old.nabble.com/Advise-needed%3A-Compontent-for-receiving-HTTP-requests-tp28339683p28343204.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Advise needed: Compontent for receiving HTTP requests

Posted by Geert Schuring <ge...@schuring.eu>.
Charles,

Thanks for your fast reply, but I think you misread my mail. I've tried to
get the servicemix-http component to work but with no luck, it keeps
giving me 404 replies.

What I need is the HTTP component to be able to receive requests on a URL
like these:
http://localhost:8192/inpact/sms?message=appelpie&originator=0031612345678

The HTTP component should then send a message like the following to the NMR:
<http-request url="/inpact/sms">
<parameter key="message" value="appelpie" />
<parameter key="originator" value="0031612345678" />
</http-request>


Geert.

> Hi Geert,
>
> The servicemix-http component can play both roles (consumer/producer)
> and so being able to do what you describe in your email. More info can
> be find here : http://servicemix.apache.org/servicemix-http.html
>
> If you don't want to use JBI specifications, you can design your
> solution using camel components : http://camel.apache.org/jetty.html /
> http://camel.apache.org/http.html
>
> Kind regards,
>
> Charles Moulliard
>
> Senior Enterprise Architect (J2EE, .NET, SOA)
> Apache Camel Committer
>
> *******************************************************************
> - Blog : http://cmoulliard.blogspot.com
> - Twitter : http://twitter.com/cmoulliard
> - Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>
>
>
> On Fri, Apr 23, 2010 at 12:27 PM, Geert Schuring <ge...@schuring.eu>
> wrote:
>> Hey all,
>>
>> I need some advice about the following:
>>
>> We're using an SMS Gateway service that sends received SMS messages to
>> our
>> system using HTTP POST requests with the message and sender in the
>> request
>> parameters.
>> Initially I though it wouldn't be a problem to receive these messages
>> using the servicemix-http component, but as it turns out this component
>> can only create some sort of proxy for other JBI endpoints.
>>
>> What I need is a BC that I can configure to listen at a certain URL and
>> that sends a message to the NMR for every HTTP request that is received
>> on
>> this URL. I can then use standard servicemix components to transform the
>> message and send it to our processing server.
>>
>> As far as I can see (I'm new to servicemix, just started researching it
>> a
>> week ago) I need to create a custom BC to realize this scenario.
>>
>> What do you think about this?
>>
>> Geert.
>>
>>
>
>
>



Re: Advise needed: Compontent for receiving HTTP requests

Posted by Charles Moulliard <cm...@gmail.com>.
Hi Geert,

The servicemix-http component can play both roles (consumer/producer)
and so being able to do what you describe in your email. More info can
be find here : http://servicemix.apache.org/servicemix-http.html

If you don't want to use JBI specifications, you can design your
solution using camel components : http://camel.apache.org/jetty.html /
http://camel.apache.org/http.html

Kind regards,

Charles Moulliard

Senior Enterprise Architect (J2EE, .NET, SOA)
Apache Camel Committer

*******************************************************************
- Blog : http://cmoulliard.blogspot.com
- Twitter : http://twitter.com/cmoulliard
- Linkedlin : http://www.linkedin.com/in/charlesmoulliard



On Fri, Apr 23, 2010 at 12:27 PM, Geert Schuring <ge...@schuring.eu> wrote:
> Hey all,
>
> I need some advice about the following:
>
> We're using an SMS Gateway service that sends received SMS messages to our
> system using HTTP POST requests with the message and sender in the request
> parameters.
> Initially I though it wouldn't be a problem to receive these messages
> using the servicemix-http component, but as it turns out this component
> can only create some sort of proxy for other JBI endpoints.
>
> What I need is a BC that I can configure to listen at a certain URL and
> that sends a message to the NMR for every HTTP request that is received on
> this URL. I can then use standard servicemix components to transform the
> message and send it to our processing server.
>
> As far as I can see (I'm new to servicemix, just started researching it a
> week ago) I need to create a custom BC to realize this scenario.
>
> What do you think about this?
>
> Geert.
>
>