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.

Reply via email to