How to Send POST method with multipart request using CAMEL - apache-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

Related

No endpoint could be found for - Camel Http Integration

I'm trying to run a simple test with Apache Camel:
from("http://localhost:61554/api/v1/MyController/my-endpoint")
.to("direct:a")
.log("$({body}");
I'm getting the following error: "No endpoint could be found for: http://localhost:61554/api/v1/MyController/my-endpoint, please check your classpath contains the needed Camel component jar"
I'm very new to Camel and Java. Can someone please tell me why this error is coming up? Should I be using from("direct:x")... ? If, so where do I map my "direct" endpoints to concrete ones?
Thanks
You cannot use the http component as consumer (eg in from) - its a http client for calling HTTP servers (so its a producer, eg to).
Instead to have HTTP as consumer you can use camel-servlet, camel-jetty, camel-undertow, etc.

extend camel http to add common header for all http request

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

Apache flink external api call

Is it possible to call an external api (RESTful) inside apache flink code. If it is possible then how we can do that.
I am calling an api from simple java code, it is working fine but when i use the same code in apache flink, it throws an exception :
java.io.IOException: Server returned HTTP response code: 500 for URL: http://example.com/someapi
Is it possible to call an external api (RESTful) inside apache flink code. If it is possible then how we can do that.
You can use the Async I/O feature provided in Flink Streaming API. Flinkā€™s Async I/O API allows users to use asynchronous request clients with data streams. More details and examples here.
java.io.IOException: Server returned HTTP response code: 500 for URL: http://example.com/someapi
This seems to non-flink error since the response is 500. Check the request headers/parameters that is being sent and verify if the http request is being properly created. Try some utilities like PostMan to test the API first.

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.

camel invoke third party webservice

I am new to the Fuse-camel,cxf.
i wan to invoke third party webservice. i don't want to use wsld2java or serviceclass. I have a wsdl.
Here is the requirement to make generic webservice call
json request data-->generate soap request --> cxf:endpoint in PAYLOAD format-->soap response -->json response data to client.
1 . how do i convert json to soaprequest(xml) and vice-versa ( Marshall-format-soapjxab is expecting jaxb annotated classes)
2.how do I call in soap in payload mode..
any help (link/example) is greatly appreciated.
Thanks,
Narendra
You can use Camel CXFRS to set up rest endpoints.
On parsing the JSON, set the values to JAXB annotated POJO's.
Then use ProducerTemplate to send SOAP request to third party service.
On receiving the response you can unmarshal it, either using JAXB unmarshaller in java code or incase of DSL use Camel JAXB DataFormat
Route the response to the client by setting the content in camel exchange.

Resources