Joe
Joe

Reputation: 115

Using Camel to get data from a web service

There is a lot of information for using Camel with JMS, but I can’t find much on using Camel to request data from a web service. I am wondering if this is even possible to do this directly, or do I need to use some kind of JMS/queue?

Ideally, I want my service (using java DSL) to send out a request to another web service, retrieve the data, and then store this in a file locally. Is it possible to do this in Camel using a simple custom RouteBuilder and a camelContext? I’ve tried setting up my routes using

`from(“http:..”).to(“file:...");` 

but this doesn’t seem to work, as it doesn’t seem to get the data from the web service. From what I've read, I was under the impression that the endpoint http: will build the request automatically and route this to a file.

I am now wondering what I could try next, and if this is even possible.

Upvotes: 1

Views: 3546

Answers (3)

Joe2013
Joe2013

Reputation: 997

It is definitely possible. The best example to start with is the CXF-Proxy Example. This shows how to invoke a remote web-service from Camel. Feel free to ask specific questions if you run into issues and we can help.

Upvotes: 3

s.k
s.k

Reputation: 535

If you don't mind trying things out at the SOAP level you could try out the approaches found here http://camel.apache.org/soap.html link. Its worth a look even if you end up using something a little more high level.

Upvotes: 1

Sergey
Sergey

Reputation: 1361

Also you could use Spring Web Services Component

http://camel.apache.org/spring-web-services.html

In this case, your route would look like:

from("<some event to trigger the route>")
.to("spring-ws:<endpoint of the WS you want to use>")
.to("file:<write the WS result>")

Upvotes: 1

Related Questions