WCF Web 服务元数据发布禁用错误

发布于 2024-09-13 01:20:10 字数 2015 浏览 2 评论 0原文

我修改了 web.config 以添加自定义绑定,以增加缓冲区和消息大小,并且似乎在显式创建服务元素时,它以某种方式破坏了对我的行为元素的引用。

当我尝试使用 WCF 测试客户端从 VS 运行我的 Web 服务时,或者我转到服务页面时,我收到错误:

Metadata publishing for this service is currently disabled.

我已将我的 web.config 与此上的几个不同源进行了比较,一切似乎都匹配。我不知道问题是什么。

这是 System.serviceModel 元素:

<system.serviceModel>    
<services>
  <service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="http://localhost:1895/BIMIntegrationService.svc" 
              binding="customBinding" bindingConfiguration="customBinding0" 
              contract="BIMIntegrationWS.IBIMIntegrationService"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadataBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <customBinding>
    <binding name="customBinding0">
      <binaryMessageEncoding />
      <httpTransport maxReceivedMessageSize="262064"
                   maxBufferSize="262064"
                   maxBufferPoolSize="262064" />
    </binding>
  </customBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"  aspNetCompatibilityEnabled="true"/>

看起来 Web 服务页面几乎没有找到该元素。我没有收到错误消息,抱怨目标行为配置不存在或类似的内容,只是未启用元数据发布。

任何帮助将不胜感激。

谢谢。

I modified my web.config to add a custom binding in order to increase the buffer and message size, and it seems like in creating the service element explicitly, it has somehow broken the reference to my behavior element.

When I try to run my web service from VS using the WCF Test Client, or I go to the service page, I get the error:

Metadata publishing for this service is currently disabled.

I've compared my web.config to a few different sources on this and everything seems to match. I've no idea what the issue is.

Here is the System.serviceModel element:

<system.serviceModel>    
<services>
  <service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="http://localhost:1895/BIMIntegrationService.svc" 
              binding="customBinding" bindingConfiguration="customBinding0" 
              contract="BIMIntegrationWS.IBIMIntegrationService"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadataBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <customBinding>
    <binding name="customBinding0">
      <binaryMessageEncoding />
      <httpTransport maxReceivedMessageSize="262064"
                   maxBufferSize="262064"
                   maxBufferPoolSize="262064" />
    </binding>
  </customBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"  aspNetCompatibilityEnabled="true"/>

It almost seems like either the web service page is not finding the element. I don't get an error complaining that the target behaviorConfiguration doesn't exist, or anything like that, just that Metadata publishing is not enabled.

Any help would be greatly appreciated.

Thanks.

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

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

发布评论

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

评论(2

眼泪也成诗 2024-09-20 01:20:11

我想我已经“解决”了这个问题。稍后还会有更多内容。

编辑:
为了“解决”我的问题,我基本上向我的应用程序添加了一个新的 WCF 服务,并让它实现了我以前的接口,然后我从原始服务中复制了所有代码,并在调整 .config 文件时(看起来很漂亮)就像问题中发布的那样),一切正常。

当然,我知道,就像我们都知道的那样,这里没有魔法,一定存在一些差异。这时我注意到/记得,在创建了名为“BIMIntegrationService.svc”的原始服务后,我认为这个名称太长,因此我将我的类重命名/重构为“BIMIntegrationWS”。但是,这样做不会更改服务文件的名称(因此也不会更改 http:// 地址中的文件名称)。

长话短说,我对 .config 进行了 2 处更改,一切正常:

1)我更改

<service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">

<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="metadataBehavior">

:像这样运行服务后,我收到一个错误(这次很有用),抱怨如果启用了 multipleSiteBindings,则端点地址必须是相对的。所以:

2)我将其设置为 false (因为我不记得为什么它首先在那里)并且一切正常。

我想当我的网络服务似乎根本没有使用我的“服务”元素时,我应该采取暗示。 :\

编辑2:

实际上,您可以在我的第二条评论中看到,在原来的问题中,自动生成的标签指向: ,而不是“BIMIntegrationService”。
那应该把它放弃了。

我怀疑其他很多人都会遇到同样的问题,但以防万一。

I think i've "fixed" the issue. More coming later.

EDIT:
In order to "fix" my issue, I basically added a new WCF service to my application, and had it implement my previous interface, I then copied all the code from my original service and when I tweaked the .config file (to look pretty much like the one posted in the question), everything worked fine.

Ofcourse, I know, like we all know, that there is no magic here, that there must be some discrepancy. This is when I noticed/remembered, that after I had created my original service, called "BIMIntegrationService.svc", I had decided that this was too long of a name, so I renamed/refactored my class to "BIMIntegrationWS". Doing this, however, does not change the name of the service file (and therefore the name of the file in the http:// address).

Long story short, I made 2 changes to my .config and everything worked:

1) I changed:

<service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">

to

<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="metadataBehavior">

After running the service like this, I got an error (a helpful one this time) complaining that if multipleSiteBindings was enabled, the endpoint address had to be relative. So:

2) I set that to false (because I don't remember why it was in there in the first place) and everything worked fine.

I guess I should have taken a hint when it seemed like my web service was not using my "service" element at all. :\

EDIT 2:

Actually, you can see in my second comment, in the original question, that the auto-generated tag was pointing to: , as opposed to "BIMIntegrationService".
That should have given it away.

I doubt many other people will have this same issue, but just in case.

淡笑忘祈一世凡恋 2024-09-20 01:20:11

我也遇到过同样的烦恼;我已经正确配置了所有内容(甚至从我运行的先前服务中复制了代码),但在允许服务公开元数据方面没有任何更改。然而,如果我对 app.config 犯了拼写错误、解析错误等,我会得到异常,告诉我纠正问题(这告诉我服务正在读取配置,只是忽略它。

我能够绕过通过在主机应用程序中生成配置设置:

System.ServiceModel.Description.ServiceMetadataBehavior smb = new System.ServiceModel.Description.ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
ServiceBase host = new Servicebase(typeof(MyService), new Uri("http://localhost:1234/"));
host.Description.Behaviors.Add(smb);
host.Open();

...

host.Close();

基本上允许代码覆盖并推送我想要应用的配置文件更改我知道这并不理想,但我通过 Windows 服务公开了该服务,这使得这成为可能。如果您确实解决了问题,请传递解决方案,因为我很想知道为什么(至少在您的情况下,如果不是我们的情况)它失败了。

I've had the same trouble; I've gotten everything configured correctly (even copied the code from a previous service I have running) and yet no change on allowing the service to expose metadata. yet, if I make a spelling error, parse error, etc. to the app.config I'm given exceptions telling me to correct the problem (which tells me the service is reading the config, just disregarding it.

I was able to bypass it by generating the config settings in the host application:

System.ServiceModel.Description.ServiceMetadataBehavior smb = new System.ServiceModel.Description.ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
ServiceBase host = new Servicebase(typeof(MyService), new Uri("http://localhost:1234/"));
host.Description.Behaviors.Add(smb);
host.Open();

...

host.Close();

Basically allow the code to override and push the config file changes i wanted applied. I know it's not ideal, but I was exposing the service through a windows service which made this do-able. if you do get your problem resolved, please pass along the solution though as I'd be curious to know why (at least in yours, if not both our cases) it's failing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文