Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring HTTP POST request from Nifi

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

like image 366
Pankesh Avatar asked Aug 24 '16 06:08

Pankesh


1 Answers

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

like image 148
Greg Oks Avatar answered Oct 30 '22 14:10

Greg Oks