从Nifi配置HTTP POST请求 [英] Configuring HTTP POST request from Nifi

查看:1412
本文介绍了从Nifi配置HTTP POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从REST客户端访问WCF服务.我正在从REST客户端向WCF服务发送POST请求.供您参考,详细信息如下.

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.

服务合同的定义如下:

[ServiceContract]
public interface IBZTsoftsensor_WcfService {

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

此接口的实现如下:

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;
  } 
 }

我从REST客户端请求此WCF服务,如下所示:

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

作为扩展,我必须从NiFi处理器访问此WCF服务. 能否请您告诉我如何在Nifi中配置处理器以访问此WCF服务??在Nifi处理器中,有一个POSTHTTP处理器(文档:

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?

或者可能会使用其他处理器invokeHTTP? (文档: https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.InvokeHTTP/index.html )

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 )

我尝试配置invokeHTTP处理器.以下是配置参数.但是,我无法访问WCF服务.

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

更多参数如下:

and more paremeters are as follows:

推荐答案

InvokeHttp处理器将流文件的内容用作请求请求的正文. 您必须在invokeHttp之前有一个处理器来设置流文件的内容,例如replaceText处理器.

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.

也不要忘记在invokeHttp处理器中将发送消息正文"属性设置为"true"

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

这篇关于从Nifi配置HTTP POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆