0
votes

I am trying to access a WCF service from a browser. I am sending a GET request from my browser to a WCF service. For your reference, the detail is as follows of a WCF service is as follows.

The Service Contract definition is as follows:

    [ServiceContract]
    public interface IBZTsoftsensor_WcfService {

    [OperationContract]
   [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "json/?inputModel={inputModel}")]
      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;
  } 
 } 

When I am accessing this WCF Service from browser with the URL

http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/json/?inputModel={"Pyro":"30.0","O2":"20.0"} 

My WCF service is responsing successfully.

However, Using the above URL, when I am configuring GeTHTTP Nifi processor, the processor is erroring illegal characters in GET request URL.

Could you please advise me - what changes I have to made in GET URL , while using GetHTTP processor?

1

1 Answers

3
votes

You may need to encode your inputModel parameter, you can use the urlEncode method of NiFi Expression Language:

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#urlencode

Try this as the URL property:

http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/json/?inputModel=${literal("{\"Pyro\":\"30.0\",\"O2\":\"20.0\"}"):urlEncode()}

Alternatively since your URL is fixed you can just encode it using an online encoding tool, which gives something like this:

http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/json/?inputModel=%7B%22Pyro%22%3A%2230.0%22%2C%22O2%22%3A%2220.0%22%7D%20