NiFi How to use InvokeHTTP Processor with SOAP

做~自己de王妃 提交于 2019-12-23 04:31:13

问题


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


回答1:


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:

Properties of GenerateFlowFile and ReplaceText Processors:

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.



来源:https://stackoverflow.com/questions/49457764/nifi-how-to-use-invokehttp-processor-with-soap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!