Apache Camel Restlet Consumer and Producer - web-services

I want to use a camel component that provides ability to consume and produce RESTful resources.
For this instance, I want to use camel restlet component.
Everything works fine with restlet component, i have successfully implemented restlet consumer using REST DSL. However I few questions:
Questions
1) Is it safe to enable restlet as async ? I have read restlet async could cause some problems. is that still correct ? how i can increase service performance? should i use jetty instead? how?
2) how i can use restlet as producer such that i can make HTTPS calls to multiple HTTP services? any examples?
3) What other camel component can be used as consumer and producer as Restful services, is Jetty/CXF easy to configure?
4) How I can enable LDAP security with components (servlet/restlet/jetty...) that provide HTTP based endpoints for consuming and producing HTTP request.
thank you. I am using latest version of camel 2.18.2 with spring-boot 4.

Ad 1)
Yes its still a bug/issue in restlet itself
Ad 2)
Check the unit tests of camel-restlet for producer examples
Ad 3)
Check the components listed on rest-dsl documentation and then CXF-RS can also do rest
Ad 4)
That is component specific if they offer any security. Check the documentation.
And your questions are too many and too broad to give better help. Try out some more yourself first.

Related

Testing Applications for use of Web Services

1) Is it possible using burp suite/ ZAP or any other web testing tools to find out
if an application is making calls to web services?
2) As SOAP web services reply in XML is it also possible to view the responses of
the HTML request to distinguish between use of REST web services?
Thanks
Yes, this is normally possible.
You need to configure the application to use the interactive proxy (Burp, Zap, etc.) as its proxy. Most applications will use your system proxy settings.
Once the proxy is configured, you can see a full history of HTTP interactions (in Burp: Proxy > HTTP History). This includes requests and responses, which will clearly indicate a SOAP or REST service.

web client call server, server call 3rd party, all async?

I have a website that is that is architected using an n-layer approach. The problem I have is that I need the client to make a call to the application layer, one of the other layers will then make a call to another web service somewhere in the world. The other web service could take some time to come back so what I would like to do, if possible, something along the lines of the following using async requests:
The client is HTML & JavaScript, the server layers are written in C# (.NET 4.5), the 3rd party web services are just web services I need to consume
How would you go about writing this?
Any help will be much appreciated
It doesn't look like the server-side code needs to call the external service asynchronously. I'm not seeing an advantage in doing that.
The client-side code would call the server-side code asynchronously, of course. (An AJAX request, using jQuery for example.) And it would await the response form that service in an asynchronous manner before handling that response. But since the server-side code in this request is only serving that one request, it can do so synchronously.
Indeed, if the server-side code were itself also asynchronous then it would return control to the client-side code immediately before it has anything useful to give it. Which means the client-side asynchronous handler can't do anything. Instead, when the server-side code gets a response from the external service, it would need to push that response to the client-side code. Which is possible with websockets and whatnot, but probably a lot more complex than this situation requires.
Only the first link in the chain needs to be asynchronous in order to provide the user experience of asynchronicity, the rest of the system doesn't need to be.
Whenever you have a "client/server" boundary, you have the option of making the server asynchronous as well as the option of making the client asynchronous. Those decisions are independent.
I'll make the assumption that your third-party webservice is scalable, or that your server has other things to do besides just this one request. In that case, I'd recommend that your server be asynchronous.
Asynchronous programming is natural with async/await in ASP.NET 4.5. Depending on your third-party service, you may want to use HttpClient or the async-compatible WCF or webservice proxies. Both ASP.NET MVC and WebAPI support asynchronous calls for your service.
On the client side, you have no choice; JavaScript in the browser must be asynchronous.

Asynchronous Webservice

I wanted to clear something about Asynchronous Webservices.
I read that weblogic give you the ability to create Asynchronous Webservices.
but I also read that it's only supported as log as the client and the server of the webservice both working under Weblogic container.
Is that true?
is it possible to create Asynchronous Webservices without having the need to have the same system(weblogic, jboss) both at client adn server side?
In case it's possible I would like to get details how is it working..
thanks,
ray.
Neither WS-Addressing nor Weblogic have anything to do with enabling async services. See the Asynchronous Client documentation for JAX-WS. There are two basic approaches supported: Static stubs and the Dispatch API. Static stubs require the use of customizations and will result in additional methods being added to the service endpoint interface. These methods expose both polling and callback functionality for async invocation.
I understood that I can invoke async webservice as long as both the server and the client supports: WS-Addressing specification.
ray.

Consume Java CXF WS exposed over SOAP from ServiceStack client

Context:
I'd like to use ServiceStack to build a SOAP client in order to consume an existing Java CXF WebService, exposed over SOAP with defined WSDL (I have no control over the WS itself). I may need to add a couple of extra headers the SOAP envelope for authorization purposes.
Question:
Would all of the above be possible, and if so, what are the gotchas? If there are any specific examples, links would be welcome.
Actually the other way round of having other clients consuming ServiceStack web services would make more sense.
Using ServiceStack to consume other clients is not an ideal strategy. ServiceStack server and client supports a coarse-grained, DTO-first approach, it wouldn't handle variations in this theme that other frameworks spit out.

How to implement asynchronous request response in REST based web service

I have a REST based web service system. I need to find a way to support publish/subscribe model here. As you know REST the communication between client and server is HTTP protocol. I use apache (PHP) web server in the backend to server all REST requests. The question is how to use PHP or whatever (in the web server side) to support this kind of Pub/Sub model. One typical scenario would be:
1) Client subscribes for a change in an object (GET /config/object/?type=async)
2) Client does not block with this request as it is async call.
3) Server accept the subscription and waits for the event.
4) Server publishes the client with the required data as and when the event happens.
I basically need to know how to implement all of these four steps above.
You are probably looking for something like PubSubHubbub -
http://code.google.com/apis/pubsubhubbub/
Letting PubSub implement the hub for you means you don't need blocking calls to the server.
They already have implemented example Subscribers and Publishers in different languages.
If haven't already, you should read Roy Fielding's take on the various approaches to PubSub. http://roy.gbiv.com/untangled/2008/paper-tigers-and-hidden-dragons