简体   繁体   中英

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.

I have been playing around with a WCF service now for the last few days and I'm starting to lose my mind. 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).

My interface and web.config are as below.

Interface:

public interface IEMEACommonOperations
{
    *Other interface Code*

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

Relevant 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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