我正在尝试从浏览器访问WCF服务。我将从浏览器发送一个GET请求到WCF服务。供您参考,WCF服务的详细信息如下所示。
服务合同的定义如下:
[ServiceContract]
public interface IBZTsoftsensor_WcfService {
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "json/?inputModel={inputModel}")]
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;
}
}
当我使用URL从浏览器访问WCF服务时
http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/json/?inputModel={"Pyro":"30.0","O2":"20.0"}
我的WCF服务成功响应了。
但是,使用上面的URL,当我配置GeTHTTP
Nifi处理器时,处理器将错误地处理GET请求URL中的非法字符。
请您告诉我-,我在使用GetHTTP处理器时,必须在GET URL中做哪些更改?
发布于 2016-08-24 08:06:57
您可能需要对inputModel参数进行编码,可以使用NiFi表达式语言的urlEncode方法:
https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#urlencode
作为URL属性尝试如下:
Addresses/WcfServiceLibrary1/Service1/json/?inputModel=${文字(“{\”Pyro\:\“30.0\”,\“O2\”:\“20.0\”}):urlEncode()}
或者,由于您的URL是固定的,所以您只需使用在线编码工具对其进行编码,这将提供如下内容:
https://stackoverflow.com/questions/39127862
复制相似问题