繁体   English   中英

WCF不解码WebGet方法上的参数

[英]WCF not decoding parameters on WebGet method

我有一个.NET 4.5 WCF服务。 在我的本地主机和另一台服务器上,方法参数正确传递。 但是,在其他服务器上,方法参数仍保持编码状态。

例如,如果我使用以下命令:

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

调用此方法:

[OperationContract]
[WebGet(UriTemplate = "AddCalendarItem/?startDate={startDate}",
ResponseFormat = WebMessageFormat.Json)]
AddCalendarItemResponse AddCalendarItem(string startDate);

在本地(Windows 8)计算机和一台服务器(Windows Server 2008 R2)上,我得到了预期的字符串: “ 09/26/2013 7:40 PM”

但是,在一台具有相同代码和配置的服务器(Windows Server 2012)上,我得到: “ 09%2f26%2f2013 9%3a30PM”

我无法确定问题出在主叫方还是被叫方。

知道是什么原因导致解码不足? 频道可以是双重编码吗?

那里的铅是什么?

现在尝试,它应该可以工作,

  [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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM