因此,今天我决定从WCF服务中删除.svc文件,并开始在线查看。从WCF服务中删除.svc导致没有发现端点
这里是一步我所做的步骤:
第1步:我加在Global.asax
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add(new ServiceRoute("Authorization", new WebServiceHostFactory(), typeof(Authenticator)));
RouteTable.Routes.Add(new ServiceRoute("Miscellaneous", new WebServiceHostFactory(), typeof(Misc)));
}
注:验证器和其它都是我的接口实现
第2步:我启用了asp.net兼容性
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
第3步:我将[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
添加到我的每个接口实现中。
第4步:我不得不将[WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest)]
添加到我的界面中的每个方法。我不知道这是干什么的,但是没有它就会发生错误。
现在它“起作用”,但是当我导航到root/Authorization(授权是我第一个服务的名称)时,它告诉我没有找到端点。
我的终点在我的web.config指明为:
<service name="AuthenticatorService.Authenticator">
<endpoint address="auth" binding="basicHttpBinding" name="AuthEndpoint"
contract="AuthInterface.IAuthenticator" />
<endpoint address="mex" binding="mexHttpBinding" name="MetadataEndpoint"
contract="IMetadataExchange" />
</service>
我很新的WCF因此它可能是一些愚蠢的错误。
嗯,你为什么要删除.svc文件? – DOK 2012-04-01 17:25:19
因为我读过,你可以,我不喜欢那里。 – TheGateKeeper 2012-04-01 17:26:30
有时,在开始试图偏离标准实践之前,以正常方式学习新技术会更容易。尤其是如果你没有充分的理由选择(不仅仅是不喜欢它)。如果你感觉固执,你可以仔细阅读右边的“相关”链接,你会发现[WCF移除.svc扩展](http://stackoverflow.com/questions/7354616/wcf-removing-svc-extention )等等。 – DOK 2012-04-01 17:33:47