为什么此WCF服务无法识别UriTemplate参数?

Kev*_*ock 7 rest wcf web-services

我已经创建了以下RESTful WCF服务,在VS中运行它时工作得很好.

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, 
    UriTemplate = "/sales/start={start}&end={end}")]
List<Sales> GetSalesByDate(string start, string end);
Run Code Online (Sandbox Code Playgroud)

但是,当将其部署到我的测试服务器(运行Win2K3和IIS6)时,我收到以下服务器错误:

合同'ISalesService'中的'GetSalesByDate'操作使用GET,但也有body参数'start'.GET操作不能有一个正文.将参数"start"设置为UriTemplate参数,或者从WebGetAttribute切换到WebInvokeAttribute.

显然我已经'开始'了一个UriParameter.所以有人能告诉我为什么会抛出异常吗?

编辑:作为参考,这是我的配置文件:

<?xml version="1.0"?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="Services.SalesService">
                <endpoint behaviorConfiguration="webBehavior" 
                          binding="webHttpBinding" 
                          contract="Services.ISalesService"/>
            </service>
        </services>
        <behaviors>
            <endpointBehaviors>
                <behavior name="webBehavior">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Kev*_*ock 10

原来这/sales/start={start}&end={end}不是一个有效的Uri(呃!).经过一番试验和错误,我终于弄明白了.使用'?'调整UriTemplate 解决了这个问题.

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, 
    UriTemplate = "/sales/?start={start}&end={end}")]
List<Sales> GetSalesByDate(string start, string end);
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!