Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当前已使用WebGet禁用此服务的WCF元数据发布_C#_Wcf_Web Config - Fatal编程技术网

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

C# 当前已使用WebGet禁用此服务的WCF元数据发布,c#,wcf,web-config,C#,Wcf,Web Config,首先,我已经遵循了一系列类似的Q,以便遵循一般问题列表,但这些问题尚未解决我的问题 在过去的几天里,我一直在玩WCF服务,我开始失去理智了。我的最终目标是尝试通过web调用提供一个方法“ping”,目前,当我尝试通过浏览器调用我的方法时,会得到一个空白页面(当调用http LocalDomain/EMEACommonOperations.svc/webHttp/ping时) 我的界面和web.config如下所示 接口: public interface IEMEACommonOperation

首先,我已经遵循了一系列类似的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>
但是,当我运行此操作时,会出现“此服务的元数据发布当前已禁用”的错误。我已经设法缩小范围,仅当我的行为节点输入了name属性时才出现,但我不相信这是问题的直接根源


我很确定我的配置文件设置有误,但我就是看不出错误。

所以经过一天的搜索,我终于注意到了我的问题。 经过进一步检查,我需要完全限定服务节点中类/接口的名称空间。我以前曾经这样做过,但是当我做出更改时,我出现了一个新的错误并忽略了结果。坏主意

因此,我的配置文件的相关部分变成:

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

更新名称空间后出现的错误与我的接口的方法采用了超过1个参数有关,因此需要将webInvoke属性BodyStyle设置为Wrapped

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