You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Michael.Murphree" <Mi...@compuware.com> on 2008/09/15 20:56:24 UTC

Proxying web services

Greetings,

I'm trying to configure an interceptable web services proxy using Camel
1.4.0.  My initial thought was to attempt to create a simple HTTP proxy:

...
from("jetty:http://localhost:8080/services/myService")
        .to("http://otherhost:80/Service1.asmx");
...

The hope was that this would also expose features like using ?wsdl in a
browser, for example.  What seems to happen instead is that query parameters
are stripped from the incoming GET request, and the request type is
converted into a POST.

I have several .Net web services running in another application that I'm
trying to provide a transparent front end for.  Rather than manually code
(or generate) separate implementations for each WS, I'd rather pass the
requests through in a manner that permits interception in later
implementations.  Is there a better way to do this?  What am I doing wrong?

Regards,

Michael Murphree
-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19498936.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Proxying web services

Posted by "Michael.Murphree" <Mi...@compuware.com>.
Hi Claus,

Thank you for the reply.

It would certainly be nice-to-have functionality if I wanted a simple HTTP
proxy route.  I'll add a JIRA ticket for this.

If I wanted to build the route myself, I take it I'll need to do things like
examine the incoming request to determine if it's a GET or a POST (for
example) and then reset those values accordingly.  BTW: I tried the syntax
you suggested to force a GET and Eclipse balks at the use of that enum.

Let me backtrack a bit and explain the environment.  I'm working with Camel
in an OSGi environment (Equinox) using Spring DM and a number of other
elements (like CXF and Muse).  I'm currently running the whole stack as a
launch configuration in Eclipse Ganymede.  HttpMethods is an enum, and
although the camel-http bundle exports that package, the JDT couldn't
resolve it.  I had to copy the source into my bundle as my own enum to make
it work.  (I suspect the Spring XML syntax would simply work, but I wanted
the ability to debug.)

The other thing of note is that the camel-jetty bundle appears to start it's
own embedded Jetty server.  Have you considered a plain OSGi HTTP Service
version of the Jetty component?  I haven't checked JIRA for this yet, but I
can add an enhancement ticket for this as well, if it seems good.

Regards,

Michael


Claus Ibsen wrote:
> 
> Hi
> 
> This is indeed an interesting use-case.
> 
> So basically you want Camel to pass through the query parameters from
> jetty producer to the http consumer and then return the HTTP body. 
> 
> That would be pretty cool if that worked out-of-the-box. So lets add the
> use case as a JIRA ticket ;) So please create a JIRA ticket if you need
> this feature out-of-the-box.
> 
> 
> About the POST/GET you can instrument the http componet what to use by
> setting a special header with the choice.
> http://activemq.apache.org/camel/http.html
> 
> From("xxx")
> .setHeader(org.apache.camel.component.http.HttpMethods.HTTP_METHOD,
> constant(org.apache.camel.component.http.HttpMethods.GET))
> .to("xxx")
> 
> Then you need to set the query parameters, you can do this also by setting
> a speical header
> 
> From("xxx")
> .process(new Processor()) {
> Public void process(Exchange exchange) {
> // TODO: get the query parameters from jetty
> String param = ""
> headers.put(HttpProducer.QUERY, param);
> }
> 
> http://activemq.apache.org/camel/jetty.html
> 
> 
> BTW: We have refined jetty and http component in Camel 1.5, you could try
> the 1.5-SNAPSHOT to see how far we are from supporting this out-of-the-box
> already.
> http://activemq.apache.org/camel/download.html
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19514895.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Proxying web services

Posted by "Michael.Murphree" <Mi...@compuware.com>.
Acknowledged.

Created https://issues.apache.org/activemq/browse/CAMEL-915 for
HeaderFilterStrategy injection / config.

Created https://issues.apache.org/activemq/browse/CAMEL-916 for OSGi
HttpService endpoint.


Claus Ibsen wrote:
> 
> Hi
> 
> Yes please feel free to create the two tickets.
> 
> We love contributions so if you are able to help with this then feel free.
> However any work will be on the trunk = the 1.5 release.
> http://activemq.apache.org/camel/contributing.html
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19536770.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Proxying web services

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Yes please feel free to create the two tickets.

We love contributions so if you are able to help with this then feel free.
However any work will be on the trunk = the 1.5 release.
http://activemq.apache.org/camel/contributing.html


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Michael.Murphree [mailto:Michael.Murphree@compuware.com] 
Sent: 17. september 2008 17:54
To: camel-user@activemq.apache.org
Subject: RE: Proxying web services


1.4.0 wasn't coded to use a strategy class so I had to modify the component
for the Proof of Concept I'm working on.  It would indeed be a useful
improvement to allow injection of a filter strategy object.  Would you like
me to add another JIRA ticket for such an improvement?  How about an
enhancement ticket for the OSGi HTTP Service producer endpoint?

Regards,

Michael


Claus Ibsen wrote:
> 
> Hi
> 
> We might need to expose some kind of easier injection / alternation of the
> xxxHeaderFilterStrategyt the endpoint is configured with. So end users as
> in this case easily can customize it. In some cases end-users doesn't want
> to filter all headers, and in others they do. 
> 
> It should be easily configurable from spring XML as well. Quickly looking
> at the http component you need to alter the HttpComponent to set your own
> HttpHeaderFilterStrategy. I think it should be configurable on the
> endpoint, then end users can set a URI option, or a setter on the endpoint
> itself. Then it's easily configurable in Spring as well.
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com] 
> Sent: 17. september 2008 01:46
> To: camel-user@activemq.apache.org
> Subject: Re: Proxying web services
> 
> Hi Micheal,
> 
> The CAMEL-766[1] will explain this stripping for handling the 
> "ProtocolHeaders".
> You can override the HttpHeaderFilterStrategy yourself and inject it 
> into the http component.
> 
> [1] https://issues.apache.org/activemq/browse/CAMEL-766
> 
> Willem
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19535288.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Proxying web services

Posted by "Michael.Murphree" <Mi...@compuware.com>.
1.4.0 wasn't coded to use a strategy class so I had to modify the component
for the Proof of Concept I'm working on.  It would indeed be a useful
improvement to allow injection of a filter strategy object.  Would you like
me to add another JIRA ticket for such an improvement?  How about an
enhancement ticket for the OSGi HTTP Service producer endpoint?

Regards,

Michael


Claus Ibsen wrote:
> 
> Hi
> 
> We might need to expose some kind of easier injection / alternation of the
> xxxHeaderFilterStrategyt the endpoint is configured with. So end users as
> in this case easily can customize it. In some cases end-users doesn't want
> to filter all headers, and in others they do. 
> 
> It should be easily configurable from spring XML as well. Quickly looking
> at the http component you need to alter the HttpComponent to set your own
> HttpHeaderFilterStrategy. I think it should be configurable on the
> endpoint, then end users can set a URI option, or a setter on the endpoint
> itself. Then it's easily configurable in Spring as well.
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com] 
> Sent: 17. september 2008 01:46
> To: camel-user@activemq.apache.org
> Subject: Re: Proxying web services
> 
> Hi Micheal,
> 
> The CAMEL-766[1] will explain this stripping for handling the 
> "ProtocolHeaders".
> You can override the HttpHeaderFilterStrategy yourself and inject it 
> into the http component.
> 
> [1] https://issues.apache.org/activemq/browse/CAMEL-766
> 
> Willem
> 
> 

-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19535288.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Proxying web services

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

We might need to expose somekind of easier injection / alternation of the xxxHeaderFilterStrategyt the endpoint is configued with. So end users as in this case easily can customize it. In some cases end-users doesn't want to filter all headers, and in others they do. 

It should be easily configurable from spring XML as well. Qucikly looking at the http component you need to alter the HttpComponent to set your own HttpHeaderFilterStrategy. I think it should be configurable on the endpoint, then end users can set a URI option, or a setter on the endpoint itself. Then it's easily configurable in Spring as well.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@gmail.com] 
Sent: 17. september 2008 01:46
To: camel-user@activemq.apache.org
Subject: Re: Proxying web services

Hi Micheal,

The CAMEL-766[1] will explain this stripping for handling the 
"ProtocolHeaders".
You can override the HttpHeaderFilterStrategy yourself and inject it 
into the http component.

[1] https://issues.apache.org/activemq/browse/CAMEL-766

Willem
Michael.Murphree wrote:
> One more item on this.  In camel-http (1.4.0 and 1.5.0), the HttpBinding
> class deliberately filters out the Content-Type header on the HttpResponse
> object.  This causes a web service response to fail.  Why does the binding
> strip out the "Content-Type" header from the response?
>
> Is there a way to add it back in short of touching that code?
>
> Regards,
>
> Michael
>   


Re: Proxying web services

Posted by Willem Jiang <wi...@gmail.com>.
Hi Micheal,

The CAMEL-766[1] will explain this stripping for handling the 
"ProtocolHeaders".
You can override the HttpHeaderFilterStrategy yourself and inject it 
into the http component.

[1] https://issues.apache.org/activemq/browse/CAMEL-766

Willem
Michael.Murphree wrote:
> One more item on this.  In camel-http (1.4.0 and 1.5.0), the HttpBinding
> class deliberately filters out the Content-Type header on the HttpResponse
> object.  This causes a web service response to fail.  Why does the binding
> strip out the "Content-Type" header from the response?
>
> Is there a way to add it back in short of touching that code?
>
> Regards,
>
> Michael
>   


RE: Proxying web services

Posted by "Michael.Murphree" <Mi...@compuware.com>.
One more item on this.  In camel-http (1.4.0 and 1.5.0), the HttpBinding
class deliberately filters out the Content-Type header on the HttpResponse
object.  This causes a web service response to fail.  Why does the binding
strip out the "Content-Type" header from the response?

Is there a way to add it back in short of touching that code?

Regards,

Michael
-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19518639.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Proxying web services

Posted by "Michael.Murphree" <Mi...@compuware.com>.
CAMEL-911 submitted ( https://issues.apache.org/activemq/browse/CAMEL-911 )


Claus Ibsen wrote:
> 
> [snip]
> That would be pretty cool if that worked out-of-the-box. So lets add the
> use case as a JIRA ticket ;) So please create a JIRA ticket if you need
> this feature out-of-the-box.
> 
> [snip]
> 

-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19517803.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Proxying web services

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

This is indeed an interesting use-case.

So basically you want Camel to pass through the query parameters from jetty producer to the http consumer and then return the HTTP body. 

That would be pretty cool if that worked out-of-the-box. So lets add the use case as a JIRA ticket ;) So please create a JIRA ticket if you need this feature out-of-the-box.


About the POST/GET you can instrument the http componet what to use by setting a special header with the choice.
http://activemq.apache.org/camel/http.html

From("xxx")
.setHeader(org.apache.camel.component.http.HttpMethods.HTTP_METHOD, constant(org.apache.camel.component.http.HttpMethods.GET))
.to("xxx")

Then you need to set the query parameters, you can do this also by setting a speical header

From("xxx")
.process(new Processor()) {
Public void process(Exchange exchange) {
// TODO: get the query parameters from jetty
String param = ""
headers.put(HttpProducer.QUERY, param);
}

http://activemq.apache.org/camel/jetty.html


BTW: We have refined jetty and http component in Camel 1.5, you could try the 1.5-SNAPSHOT to see how far we are from supporting this out-of-the-box already.
http://activemq.apache.org/camel/download.html


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Michael.Murphree [mailto:Michael.Murphree@compuware.com] 
Sent: 15. september 2008 20:56
To: camel-user@activemq.apache.org
Subject: Proxying web services


Greetings,

I'm trying to configure an interceptable web services proxy using Camel
1.4.0.  My initial thought was to attempt to create a simple HTTP proxy:

...
from("jetty:http://localhost:8080/services/myService")
        .to("http://otherhost:80/Service1.asmx");
...

The hope was that this would also expose features like using ?wsdl in a
browser, for example.  What seems to happen instead is that query parameters
are stripped from the incoming GET request, and the request type is
converted into a POST.

I have several .Net web services running in another application that I'm
trying to provide a transparent front end for.  Rather than manually code
(or generate) separate implementations for each WS, I'd rather pass the
requests through in a manner that permits interception in later
implementations.  Is there a better way to do this?  What am I doing wrong?

Regards,

Michael Murphree
-- 
View this message in context: http://www.nabble.com/Proxying-web-services-tp19498936s22882p19498936.html
Sent from the Camel - Users mailing list archive at Nabble.com.