Configuring HTTP POST request from Nifi
Asked Answered
A

1

7

I am trying to access a WCF service from a REST client. I am sending a POST request from a REST client to a WCF service. For your reference, the detail is as follows.

The Service Contract definition is as follows:

[ServiceContract]
public interface IBZTsoftsensor_WcfService {

[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json,  ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/data")]
   string ExecuteModelJson(string inputModel);
}

And the implementation of this interface is as follows:

public string ExecuteModelJson(string inputModel){
  try
  {
    BZTsoftsensor_ModelInput input =   JsonConvert.DeserializeObject<BZTsoftsensor_ModelInput>(inputModel);
  var results = this.ExecuteModel(input);
  return JsonConvert.SerializeObject(results);
  }
  catch (Exception ex)
  {
    return ex.Message;
  } 
 }

From a REST client, I am requesting this WCF Service as follows:

enter image description here As an extension, I have to access this WCF service from a NiFi processor. Could you please advise me how can I configure a processor in Nifi to access this WCF service? In Nifi processor, there is a POSTHTTP processor (documentation: https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.PostHTTP/index.html) is available, however I am wondering how could I configure it?

OR possibly there could be other processor to be used invokeHTTP ?? (documentation: https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.InvokeHTTP/index.html )

I have tried to configure invokeHTTP processor. The following are configuration parameters. But, I am not able to access a WCF service.

enter image description here and more paremeters are as follows: enter image description here

Annihilation answered 24/8, 2016 at 6:38 Comment(1)
Assuming there is no handshake involved (just posting to the URL), InvokeHTTP is the processor you will want to use. When you try to run the InvokeHTTP processor does it fail with any bulletins? or does the WCF service log any errors?Phoebephoebus
L
9

InvokeHttp processor uses the content of the flow file as the body for tye request. You must have a processor before the invokeHttp that sets the content of your flow file, for example replaceText processor.

Also dont forget to set the property ‘send message body’to ‘true’ in the invokeHttp processor

Lavonda answered 23/5, 2018 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.