2
votes

Thanks to NiFi How to use InvokeHTTP Processor with SOAP, I've been able to make a SOAP call. Strategy used was to use the GenerateFlowFile processor, and insert my content into custom content. The call needed a username and password, as well as another variable or two, and expression language neatly populated it.

Good.

Now, what I really need is two SOAP calls, where the first SOAP call returns a sequence number that I provide to the second call to get the specific data file I'm returning. I've set up a ProcessorGroup for the first SOAP interaction, which results in a flow attribute being set for the sequence number.

The rub: GenerateFlowFile just works on a timer. I've not been able to fathom a way where I can use the result from the first SOAP flow to then trigger an appropriately built FlowFile for the 2nd call.

Thoughts? Things I've puzzled over but haven't yet wrestled a solution forth include RouteOnAttribute, RouteOnContent, MergeContent, Wait, ...

2

2 Answers

2
votes

You can use ReplaceText to accept an incoming flowfile with the correct sequenceNumber attribute and populate the flowfile content with the new SOAP body you need. The Replacement Value property supports Expression Language, so you could provide a value like:

  • Search Value: (?s)(^.*$)
  • Replacement Value: <xml><sequenceNumber>${sequence_number}</sequenceNumber></xml>

If you only need to replace part of the content or maintain some of the existing content text, you can use regex matching groups and backreferences to identify those.

The output from the ReplaceText processor would then be routed to a second InvokeHTTP processor to perform the second SOAP call.

2
votes

Just to add on top of what @Andy had said. The response that you receive which contains the sequenceNumber will be in XML, right? So you could use EvaluateXPath processor to parse and get the sequence number and then use the approach that Andy had mentioned. i.e. Use ReplaceText processor to generate the SOAP Request body which would be sent to the second InvokeHTTP

So the overall flow would look like:

GenerateFlowfile -> InvokeHTTP -> EvaluateXPath -> ReplaceText -> InvokeHTTP -> (YOUR_LOGIC)