[英]WCF not decoding parameters on WebGet method
I have a .NET 4.5 WCF service. 我有一个.NET 4.5 WCF服务。 On my localhost and one other server the method parameters are passed correctly. 在我的本地主机和另一台服务器上,方法参数正确传递。 However, on a different server, the method parameters remain encoded. 但是,在其他服务器上,方法参数仍保持编码状态。
For example, if I use the following: 例如,如果我使用以下命令:
var factory = new ChannelFactory<MyService.Interface.ILeadService>("MyService", new EndpointAddress(url));
var channel = factory.CreateChannel();
using (new OperationContextScope((IContextChannel)channel))
{
channel.AddCalendarItem("09/26/2013 7:40PM");
}
To call this method: 调用此方法:
[OperationContract]
[WebGet(UriTemplate = "AddCalendarItem/?startDate={startDate}",
ResponseFormat = WebMessageFormat.Json)]
AddCalendarItemResponse AddCalendarItem(string startDate);
On my local (Windows 8) machine and one server (Windows Server 2008 R2) I get the expected string: "09/26/2013 7:40PM" 在本地(Windows 8)计算机和一台服务器(Windows Server 2008 R2)上,我得到了预期的字符串: “ 09/26/2013 7:40 PM”
However, on one server (Windows Server 2012) with the same code and configuration I get: "09%2f26%2f2013 9%3a30PM" 但是,在一台具有相同代码和配置的服务器(Windows Server 2012)上,我得到: “ 09%2f26%2f2013 9%3a30PM”
I can't tell if the problem is with the caller or the callee. 我无法确定问题出在主叫方还是被叫方。
Any idea what could be causing the lack of decoding? 知道是什么原因导致解码不足? Could the channel be double-encoding? 频道可以是双重编码吗?
What is Lead there? 那里的铅是什么?
Try now, it should work, 现在尝试,它应该可以工作,
[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/AddCalendarItem/{token}?startDate={startDate}")]
AddCalendarItemResponse AddCalendarItem(string token, string startDate);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.