2011-05-06 37 views
2

无事先做题/答案使我一个完整的REST/WCF的解决方案,将删除服务的各个方面SVC扩展。从“?WSDL”和“/帮助” REST WCF服务删除.SVC仍处于启用状态

具体来说,我指的servicename/helpservicename/wsdl ...但我知道这是可能的。 Here is a working example能够从/ help链接中删除WCF扩展的人员。另外,他还不能直接使用扩展名来调用.svc。看来,WSDL是不存在的(虽然我宁愿把这个)

如何让我的WCF REST的应用程序的行为更像是链接?

这里是IIS URL重写让我有一部分的方式。这看起来有点怪异,因为如果我没有第一次(两个)重写,那么Web服务会随机获得borked。

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 


    <rewrite> 
     <rules> 
     <rule name="test1.svc" stopProcessing="true" > 
      <match url="^test1.svc(.*)$"/> 
     </rule> 
     <rule name="test1" stopProcessing="true" > 
      <match url="^test1(.*)$"/> 
      <action type="Rewrite" url="/test1.svc{R:1}" /> 
     </rule> 
     </rules> 
    </rewrite> 

    </system.webServer> 
+0

@Stephen Patten - 我注意到你是SO用户。我会看看这个记载中你会看到这个帖子... – LamonteCristo 2011-05-06 01:54:20

回答

7

我假设您使用.Net Framework 4,根据您发布的链接。如果是这种情况,则不需要使用.svc文件,因为它现在与ASP.NET routing集成。因此,您可以使用新的ServiceRoute类将您的服务URL添加到ASP.NET Route table。欲了解更多信息,请参阅以下article

+1

对于这种方法的实现[见该罗恩雅各布的文章(http://geekswithblogs.net/michelotti/archive/2010/08/21/restful -wcf-services-with-no-svc-file-and-no-config.aspx)以了解如何执行此操作。 – 2011-05-06 15:27:17

-2

WCF 4,您还可以提供别名使用fileless激活和Windows激活服务寻址。 (WAS)

<configuration> 
    <system.serviceModel> 
    <serviceHostingEnvironment> 
     <serviceActivations> 
     <add relativeAddress="/GreetingService" service="GreetingService"/> 
     </serviceActivations> 
    </serviceHostingEnvironment> 
    </system.serviceModel> 
</configuration> 
+1

不起作用。另外,任何未在IIS中注册的东西都会出现此错误:'扩展名'.t'未用WCF/WF处理程序注册。请从配置文件中删除'system.serviceModel/serviceHostingEnvironment/serviceActivations'中的relativeAddress'〜/ t1.t',或者使用WCF/WF处理程序注册相应的扩展名'.t'。请参考'http://msdn.microsoft.com/en-us/library/bb515343.aspx'了解如何在IIS中注册扩展名。' – LamonteCristo 2011-05-09 13:35:01

+0

您可能需要在.config中对“处理所有模块”进行破解,并且/或为静态内容与IIS中的动态内容设置适当的模块/处理程序。检查静态内容处理程序是否设置为期望文件夹或文件存在。 – andrewbadera 2011-05-09 14:15:06