I have a .NET 4.5 WCF service. 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"
However, on one server (Windows Server 2012) with the same code and configuration I get: "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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.