[英]Removing .svc from WCF service results in no endpoints found
因此,今天我决定要从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)));
}
注意:Authenticator和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的新手,所以可能是一些愚蠢的错误。
您在这里混合了两种技术-在您的配置中,定义了作为SOAP服务的basicHttpBinding
但是,在您的服务路由中,传入了WebServiceHost
,该WebServiceHost
用于WCF中的REST服务(基于webHttpBinding
)。
尝试一下-只需在global.asax
文件中使用“常规”(面向SOAP) ServiceHostFactory
:
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add(
new ServiceRoute("Authorization",
new ServiceHostFactory(), typeof(Authenticator)));
RouteTable.Routes.Add(
new ServiceRoute("Miscellaneous",
new ServiceHostFactory(), typeof(Misc)));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.