网址 - http:// localhost
:8000 / MyFirstRestService正常运行
但http:// localhost
:8000 / MyFirstRestService?tag = zx无效。
不确定我错过了什么。请建议
合同:
namespace WcfRESTService
{
[ServiceContract]
public class BookmarkService
{
[WebGet(UriTemplate = "?tag={tag}")]
[OperationContract]
string GetPublicBookmarks(string tag)
{
if (tag.Equals("Test1"))
{
return "true";
}
else
{
return "false";
}
}
主要功能
Uri baseAddress = new Uri("http://localhost:8000/MyFirstRestService");
ServiceHost sHost = new ServiceHost(typeof(BookmarkService), baseAddress);
sHost.Open();
Console.WriteLine("Service Started");
配置文件:
<service name="WcfRESTService.BookmarkService" behaviorConfiguration ="RestServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="WcfRESTService.BookmarkService" behaviorConfiguration="webHttp">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<serviceBehaviors>
<behavior name ="RestServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>