解决 WCF 错误:此服务的元数据发布当前已禁用

发布于 2024-11-14 18:55:31 字数 1713 浏览 1 评论 0原文

我想发布具有自定义绑定配置的 Web 服务。我使用自定义绑定配置来增加 65536 字节的默认消息大小。我遇到的问题是,当我使用如下所示的 web.config 设置时,出现错误:

此服务的元数据发布当前已禁用。

我的主要目标是能够增加默认消息大小,因此欢迎任何其他配置,但是我试图使其尽可能简单以避免进一步的问题。

您能发现我的配置有什么问题吗?

<bindings>
  <basicHttpBinding>        
      <binding name="NewBinding0" closeTimeout="00:10:00" openTimeout="01:10:00"
     receiveTimeout="01:10:00" sendTimeout="01:10:00" maxBufferSize="99536"
     maxBufferPoolSize="5242880" maxReceivedMessageSize="99536">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="99536" maxBytesPerRead="99536" maxNameTableCharCount="2147483647" />
        <security>
          <transport clientCredentialType="Basic" />
        </security>

    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="MeterReadingOrderWSBehaviors">
      <serviceMetadata httpsGetEnabled="true" />         
    </behavior>
    </serviceBehaviors>

</behaviors>
<services>
  <service name="MeterReadingOrderWS.IMeterReadingOrderWS" behaviorConfiguration="MeterReadingOrderWSBehaviors">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:3440/MeterReadingOrderWS.svc"/> 
      </baseAddresses>
    </host>
    <endpoint address="" contract="MeterReadingOrderWS.IMeterReadingOrderWS" binding="basicHttpBinding" bindingConfiguration="NewBinding0" />
    <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpsBinding" />
  </service>
</services>

I want to publish a Webservice with custom binding configuration. I am using a custom binding configuration to increase the default message size of 65536 bytes. The problem I am having is that when I use the web.config settings as shown below, I am getting an error:

Metadata publishing for this service is currently disabled.

My Main goal is to be able to increase the default message size, therefore any other config is welcome, however I was trying to keep it as simple as possible to avoid further issues.

Can you please spot what is wrong with my configuration?

<bindings>
  <basicHttpBinding>        
      <binding name="NewBinding0" closeTimeout="00:10:00" openTimeout="01:10:00"
     receiveTimeout="01:10:00" sendTimeout="01:10:00" maxBufferSize="99536"
     maxBufferPoolSize="5242880" maxReceivedMessageSize="99536">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="99536" maxBytesPerRead="99536" maxNameTableCharCount="2147483647" />
        <security>
          <transport clientCredentialType="Basic" />
        </security>

    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="MeterReadingOrderWSBehaviors">
      <serviceMetadata httpsGetEnabled="true" />         
    </behavior>
    </serviceBehaviors>

</behaviors>
<services>
  <service name="MeterReadingOrderWS.IMeterReadingOrderWS" behaviorConfiguration="MeterReadingOrderWSBehaviors">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:3440/MeterReadingOrderWS.svc"/> 
      </baseAddresses>
    </host>
    <endpoint address="" contract="MeterReadingOrderWS.IMeterReadingOrderWS" binding="basicHttpBinding" bindingConfiguration="NewBinding0" />
    <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpsBinding" />
  </service>
</services>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

柠檬心 2024-11-21 18:55:31

我继续我的研究并遵循这篇文章解决了我的问题:

http://keithelder.net/2008/01/17/exusing-a-wcf-service-with-multiple-bindings-and-endpoints/

希望它可以帮助其他人 出色地。

I have continued my research and followed this article which solved my problem:

http://keithelder.net/2008/01/17/exposing-a-wcf-service-with-multiple-bindings-and-endpoints/

Hope it can help others as well.

小…红帽 2024-11-21 18:55:31

请注意,您的问题似乎与元数据行为有关,在此之前您必须检查服务名称
下面代码中的 ieWebApplication1.MyService ;
这应该是相同的顺序namespace.service

    <endpoint  address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceBebavior">
      <serviceMetadata  httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->

Note that your problem is seems to be related with Metadata behaviour, before that you have to check name of service
i.e.WebApplication1.MyService in below code;
this should be in same order namespace.service

    <endpoint  address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceBebavior">
      <serviceMetadata  httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->

有木有妳兜一样 2024-11-21 18:55:31

为您的服务添加行为并启用

httpGetEnabled=true

像这样:

 <behavior name="MyService.Service1Behavior">
     <serviceMetadata httpGetEnabled="true" />
 </behavior>

Add behavior for your Service and enable

httpGetEnabled=true

like this:

 <behavior name="MyService.Service1Behavior">
     <serviceMetadata httpGetEnabled="true" />
 </behavior>
无人问我粥可暖 2024-11-21 18:55:31
<serviceMetadata httpsGetEnabled="true" />

您已通过 https 启用元数据服务,但您有一个用于 mexHttpsBinding 的 http 端点。
您必须使用 https 作为端点地址。


编辑

您使用 mexHttpsBinding,因此使用 httpsGetEnabled 是正确的。如果您不想使用 https 作为元数据,请使用 httpGetEnabled 并将 mex 的绑定类型从 mexHttpsBinding 更改为 mexHttpBinding。

    <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" />
    <!--- ......- -->
    <serviceBehaviors>
       <behavior name="MeterReadingOrderWSBehaviors">
            <serviceMetadata httpGetEnabled="true" />         
       </behavior>
   </serviceBehaviors>

如果您想使用 https 来获取元数据,请考虑对每个 mex 端点使用完整的地址表示法

<endpoint address="https://localhost:3440/MeterReadingOrderWS.svc/mex" contract="IMetadataExchange" binding="mexHttpsBinding" />
<serviceMetadata httpsGetEnabled="true" />

You've enabled metadata service through https but you have a http endpoin for mexHttpsBinding.
You have to use https for you endpoint address.


Edit

You use mexHttpsBinding so it's correct to use httpsGetEnabled. If you don't want https for metadata use httpGetEnabled and change binding type for mex from mexHttpsBinding to mexHttpBinding.

    <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" />
    <!--- ......- -->
    <serviceBehaviors>
       <behavior name="MeterReadingOrderWSBehaviors">
            <serviceMetadata httpGetEnabled="true" />         
       </behavior>
   </serviceBehaviors>

If you want to use https for metadata consider to use a full address notation per your mex endpoint

<endpoint address="https://localhost:3440/MeterReadingOrderWS.svc/mex" contract="IMetadataExchange" binding="mexHttpsBinding" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文