多个参数传递wcf休息服务时找不到端点

时间:2016-02-05 08:39:30

标签: c# wcf rest wcf-endpoint

这是我的单参数OperationContract

[OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "xml/{id}")]
    XmlElement GetXmlData(string id);  

http://localhost/rest/xml/1

工作正常。

然后我想再添加一个参数。 。 。

[OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Xml,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "xml/{id}/{name}")]
    XmlElement GetXmlData(string id, string name);  

http://localhost/rest/xml/1/smith

返回“Endpoint Not Found”

我该如何解决这个问题?请帮忙。谢谢。

这是我的System.serviceModel

的web.config文件
<system.serviceModel>
<services>      
  <service behaviorConfiguration="RESTFulWCFService.PersonServiceBehavior" name="RESTFulWCFService.PersonService">
    <endpoint address="" binding="webHttpBinding" contract="RESTFulWCFService.IPersonService" behaviorConfiguration="web">          
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>        
    <behavior name="RESTFulWCFService.PersonServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>

0 个答案:

没有答案