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:
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.
and more paremeters are as follows:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With