![](/img/trans.png)
[英]WCF Service Library (IIS): Metadata publishing for this service is currently disabled
[英]WCF Metadata publishing for this service is currently disabled using WebGet
首先,我已经遵循了SO中的一系列类似的Q,这些Q遵循通用问题列表,但是这些还没有解决我的问题。
在过去的几天里,我一直在使用WCF服务,而我开始失去理智。 我的最终目标是尝试通过Web调用使用方法“ ping”,当前,当我尝试通过浏览器调用方法时,我得到一个空白页(调用http LocalDomain / EMEACommonOperations.svc / webHttp / Ping时) )。
我的界面和web.config如下。
接口:
public interface IEMEACommonOperations
{
*Other interface Code*
[WebGet]
[OperationContract]
string Ping();
}
相关的Web.Config:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="HttpGetMetadata" name="EMEACommonOperations">
<endpoint address="webHttp"
binding="webHttpBinding"
bindingConfiguration=""
name="webHttp"
contract="IEMEACommonOperations"
behaviorConfiguration="WebHttp" />
<endpoint address="mex"
binding="mexHttpBinding"
name="mex"
contract="IEMEACommonOperations" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="webHttpBinding"
textEncoding="utf-8"
openTimeout="00:01:00"
receiveTimeout="00:03:00"
closeTimeout="00:01:00" />
<binding name="mexHttpBinding"
textEncoding="utf-8"
openTimeout="00:01:00"
receiveTimeout="00:03:00"
closeTimeout="00:01:00" />
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="HttpGetMetadata">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
类:
namespace C.EMEA.Workflow.Services.BPM.HCP.ServiceClasses
{
public class EMEACommonOperations : ServiceBase, IEMEACommonOperations
{
public string Ping()
{
return DateTime.Now.ToString();
}
*Other class code*
}
}
但是,当我运行它时,出现错误“当前禁用此服务的元数据发布”。 我设法将其范围缩小到仅当我的行为节点输入了name属性时才出现,但我不相信这是问题的直接原因。
我相当确定我的配置文件设置有误,但是我无法发现错误。
因此,经过一天的搜索,我终于注意到了我的问题。 经过进一步检查,结果证明我需要完全限定服务节点中我的类/接口的名称空间。 我以前曾经这样做过,但是当我进行更改时,我遇到了一个新错误,并忽略了结果。 馊主意。
因此,我的配置文件的相关部分变为:
<service name="*FullyQualifiedNamespace*.EMEACommonOperations">
<endpoint address="webHttp"
behaviorConfiguration="WebHttp"
binding="webHttpBinding"
contract="*FullyQualifiedNamespace*.IEMEACommonOperations" />
</service>
更新名称空间后出现的错误与我的接口有关,该接口的方法带有多个参数,因此需要将webInvoke属性BodyStyle设置为Wrapped。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.