WCF Discovery 仅工作于调用的 wcf 服务

问题描述 投票:0回答:1

好的,我们开始吧。 我制作了wcf服务并通过Visual Studio 2012将其发布在IIS 7.5中。 当我使用 WCF 测试客户端时,该服务正在运行并且运行良好。

为了启用 UDP 发现,我对 app.config 进行了一些调整,如下所示:

<system.serviceModel>
<services>
  <service name="System_Core.wcf_service">
    <endpoint address="" binding="wsHttpBinding" contract="System_Core.IWCF_Service" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint isSystemEndpoint="true" kind="udpDiscoveryEndpoint" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8888" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="False" httpsGetEnabled="False" />
      <!-- 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" />
      <serviceDiscovery />
    </behavior>
  </serviceBehaviors>
</behaviors>

发布时该文件也会复制到 web.config。总之,wcf服务本身运行良好。

问题是这样的: 我做了另一个项目,需要发现网络上的 wcf 服务。但该发现仅在首次调用或手动导航到浏览器中的 .svc 之后才有效。当我在 IIS7 管理器中重新启动 IIS 或 wcf 时,发现返回失败/未收到任何响应。看来wcf没有自动启动。我检查了 IIS 配置,它会自动启动。该网站本身也设置为自动启动。我什至根据网上的一些建议将其中一些行放入 applicationHost.config 中:

 <site name="WCF" id="1" serverAutoStart="true">
            <application path="/" serviceAutoStartEnabled="true" >
                <virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\WCF" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:8888:" />
            </bindings>
        </site>


<applicationPools>
        <add name="DefaultAppPool" startMode="AlwaysRunning" managedRuntimeVersion="v4.0" />
        <add name="ASP.NET v4.0" managedRuntimeVersion="v4.0" />
        <add name="ASP.NET v4.0 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" />
        <applicationPoolDefaults>
            <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="false" />
        </applicationPoolDefaults>
    </applicationPools>

还是没用! IIS 说它“已启动”,Site 说它“已启动”,但发现仍然仅在浏览器中手动调用服务 .svc 文件后才起作用。当您重新启动服务器或站点时,它会恢复为无法工作。我相信任何服务都应该在 IIS 启动时启动,但它不会。

我在网上发现其他人也有同样的问题,但仍然没有解决。

web-services wcf autostart wcf-discovery webservice-discovery
1个回答
0
投票

我放弃并跳过所有令人困惑的内容,并安装 IIS 的初始化页面扩展,伟大的 Schwammy 在本页中对此进行了描述:

http://www.schwammysays.net/auto-starting-websites-on-iis-7-5/

效果很好,简单!

© www.soinside.com 2019 - 2024. All rights reserved.