Code Novice
Code Novice

Reputation: 2398

NiFi How to use InvokeHTTP Processor with SOAP

I see that others have been able to get this to work however I am unable to find enough detail explaining how they accomplished this in order for me to get this to work.

This guy at this link claims he was able to do this. While there is a brief description as to how to do this I don't fully understand it.

The solution presented was:

With InvokeHTTP, you can add dynamic properties, which will be sent in the request as headers. You can use dynamic properties to set values for the Content-Type and SOAPAction headers, just use the header names for the names of the dynamic properties. InvokeHTTP lets you control the HTTP method, so you can set that to POST. The remaining step would be to get the content of request.xml to be sent to the InvokeHTTP as a flowfile. One way to do this is to use a GetFile processor to fetch requeset.xml from some location on the filesystem, and pass the success relationship of GetFile to InvokeHTTP

--Jeff.

I'm using SOAPUI to verify that everything works and it does as I am getting the appropriate XML response back. However I am unable to accomplish this in NiFi. My guess is that I don't know what to call my dynamic properties. I also don't fully understand what data I'd add to the Value of my dynamic properties.

InvokeHTTP Processor Properties Screenshot:

InvokeHTTP Processor Properties Screenshot

Upvotes: 3

Views: 9999

Answers (1)

Code Novice
Code Novice

Reputation: 2398

The key here that I was missing was the need to send the xml SOAP request as Flow File Content rather than a Flow File Attribute. It took awhile before I was clued in as to how to create a Flow File with custom content.

The key with using the InvokeHTTP processor to make a SOAP request was the requirement for the InvokeHTTP processor to receive the xml SOAP request as a Flow File due to the fact that when the processor sends the http POST request it sends it's Attributes as the headers of the SOAP request and the incoming Flow File content as the SOAP Body. This took awhile to understand and after that to figure out how to customize the content of a Flow File.

My original mistake was my attempting to use the GenerateFlowFile processor by itself and send it directly to the InvokeHTTP processor. This didn't work for me as I had no clue how to convert the 'text' I placed into the GenerateFlowFile dynamic Attribute as the Content.

Finally an individual HERE clued me in as to how one could create a Flow File with custom Content by using the ReplaceText processor to convert the Attribute I had created in the GenerateFlowFile processor as the Flow File Content.

Finally I had the Flow File in the correct format that the InvokeHTTP Processor required in order to send/POST the SOAP request.

Screenshot of the Flow:

enter image description here

Properties of GenerateFlowFile and ReplaceText Processors:

enter image description here

Last we just need to add some Dynamic Attributes to the InvokeHTTP processor and submit that along with the incoming Flow File as an HTTP POST request. Again the Attributes are sent as Headers and the incoming Flow File Content is sent as the BODY. This took a little bit to understand but it's pretty easy once you have the pieces put together and setup correctly.

enter image description here

Upvotes: 10

Related Questions