extend camel http to add common header for all http request - apache-camel

currently, for a server to server communication, we have our own authentication method which will expect a random key in the HTTP request header.is there a way I can extend the camle HTTP to add the header for all the HTTP request call. Note we have 4 camel context XML and each camel context have 10 routes which make the HTTP request

You could also use Camel interceptors in order to add your custom header to (all or some) "http:*"-like endpoints.
Have a look at:
http://camel.apache.org/intercept.html

Related

Salesforce send Outbound Message as PUT

I am sending outbound messages from Salesforce. They are always sending as POST, though. Is there a way to change the method they are using?
I'd like to send some of them as PUT, instead (and, eventually, some DELETE). I'm not finding anything from Google searches.
Outbound Messages are SOAP 1.1 based, and as such are required to use POST by the SOAP 1.1 spec, so there are no options to use other HTTP methods for the Outbound Message requests.
If you want to send HTTP requests instead of SOAP messages, you'll need to write an Apex trigger and use a future method to make the HTTP request from apex.

How to turn-off/remove "server version" in HTTP response header in Fuse 6.2

HTTP Response from my ESB service contains below HTTP header details;
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Server: Jetty(7.6.7.v20120910)
How to remove/hide server version in response header.
I have tried with camel- route configuration as below;
removeHeaders pattern="*"
But its not worked out. Meanwhile i tried to intercept the response by using cxf-out-interceptor, but Message contains only content-type & date in PROTOCAL_HEADERS.
Is there any configuration in Fuse container level to remove this header key from HTTP response?
With the jetty component I think you cannot. The endpoint implementation adds back the three headers Content-Type, Transfer-Encoding, and Server even after the header filter strategy gets applied.
If you have the flexibility, try the netty4-http component instead of jetty. Possibly it does not add headers after the strategy is applied/you remove the headers explicitly with removeHeaders.
You can try to add your custom bindings instead of DefaultBindings provided by CXF if you using CXF as web service provider. In that case, you can remove/add/overrider certain attributes when headers are populated back to CXF Exchange from Camel Exchange.

Is there a way to avoid Preflighting with $http?

I'm using nginx on the remote server, and with no support for the OPTIONS method I've been terribly stuck. Both the server and angular refuse to talk to each other.
I just want to make a simple $http.post() request. Is there a way to configure the service to ONLY send the POST request, and not do any preflighting with OPTIONS?
This is not something AngularJS does, but something your browser does according to the Cross-Origin Resource Sharing standard. See also this answer on a related issue.
However, if you make it so that the AngularJS application is served from the same domain as your resource (different subdomains will affect cross-origin), then the browser will not send the OPTIONS request as the resource is no longer from a cross-origin server.
Example:
www.example.com requests resource on api.example.com will trigger OPTIONS request
www.example.com requests resource from www.example.com/api will not trigger OPTIONS request
If CORS is Unavoidable
You could change the header of the request to text/plain and then parse your response manually acording to answers in this link below
How to skip the OPTIONS preflight request in AngularJS

Apache sticky session from response header

I have a requirement where I need to route a series of requests to the same member
in a load balancer cluster.
The requests look like this:
/server/create-some-id => responds with a unique ID
/server/do-something-with-id/{ID}
/server/do-something-with-id/{ID}
... etc.
The requirement is that requests 2 and on have to be routed to the same balancer
member as request 1. Due to some legacy code, I can't just create a cookie in
the response of request 1 to use for routing.
I'm wondering if there's an Apache module which is able to SetEnvIf based on either
a response header or the response body, or any other way to solve this?
Thanks!
It does not seem to be possible to enable stickyness based on the response headers or body in Apache 2.

How to Send POST method with multipart request using CAMEL

How to Send POST method with multipart request using CAMEL
I have an application with camel setup and i need to attach documents and send and HTTP POST request.
How can i do this,
You can always write some java code with the apache httpcompenents library. see http://hc.apache.org/
It is not difficult to use

Resources