简体   繁体   English

当前使用WebGet禁用此服务的WCF元数据发布

[英]WCF Metadata publishing for this service is currently disabled using WebGet

First up, I've already followed a bunch of similar Q's from SO that follow the generic problem list but these have yet to resolve my problems. 首先,我已经遵循了SO中的一系列类似的Q,这些Q遵循通用问题列表,但是这些还没有解决我的问题。

I have been playing around with a WCF service now for the last few days and I'm starting to lose my mind. 在过去的几天里,我一直在使用WCF服务,而我开始失去理智。 My end goal is that I'm attempting to have a method "ping" available via web calls, currently when I try to call my method via a browser I get a blank page (when calling http LocalDomain/EMEACommonOperations.svc/webHttp/Ping). 我的最终目标是尝试通过Web调用使用方法“ ping”,当前,当我尝试通过浏览器调用方法时,我得到一个空白页(调用http LocalDomain / EMEACommonOperations.svc / webHttp / Ping时) )。

My interface and web.config are as below. 我的界面和web.config如下。

Interface: 接口:

public interface IEMEACommonOperations
{
    *Other interface Code*

    [WebGet]
    [OperationContract]
    string Ping();
}

Relevant Web.Config: 相关的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>

Class: 类:

namespace C.EMEA.Workflow.Services.BPM.HCP.ServiceClasses
{
    public class EMEACommonOperations : ServiceBase, IEMEACommonOperations
    {
        public string Ping()
        {
             return DateTime.Now.ToString();
        }
        *Other class code*
    }
}

However when I go to run this I get an error of "Metadata publishing for this service is currently disabled.". 但是,当我运行它时,出现错误“当前禁用此服务的元数据发布”。 I have managed to narrow this down to only appearing when my behavior node has the name attribute entered but I'm not convinced this is the direct source of my problem. 我设法将其范围缩小到仅当我的行为节点输入了name属性时才出现,但我不相信这是问题的直接原因。

I'm fairly sure I have my config file setup wrong but I just can't spot the mistake. 我相当确定我的配置文件设置有误,但是我无法发现错误。

So after a day of searching I finally noticed my problem. 因此,经过一天的搜索,我终于注意到了我的问题。 After further examination it turns out I needed to fully qualify the name space of my class/interface in the service node. 经过进一步检查,结果证明我需要完全限定服务节点中我的类/接口的名称空间。 I had originally done this before but when I made the change I ended up with a new error and ignored the result. 我以前曾经这样做过,但是当我进行更改时,我遇到了一个新错误,并忽略了结果。 Bad idea. 馊主意。

So the relevant part of my config file became: 因此,我的配置文件的相关部分变为:

<service name="*FullyQualifiedNamespace*.EMEACommonOperations">
    <endpoint address="webHttp"
          behaviorConfiguration="WebHttp"
          binding="webHttpBinding" 
          contract="*FullyQualifiedNamespace*.IEMEACommonOperations" />
</service>

The error that came about after I updated the namespaces was to do with my interfaces having methods that took more than 1 parameter and thus required webInvoke attribute BodyStyle to be set to Wrapped. 更新名称空间后出现的错误与我的接口有关,该接口的方法带有多个参数,因此需要将webInvoke属性BodyStyle设置为Wrapped。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM