简体   繁体   中英

WCF Discovery working only wcf service called

Ok let's start. I make wcf service and publish it in IIS 7.5 via Visual Studio 2012. The service is running and works well when I use WCF test client.

To enable UDP discovery, i make some adjustment on app.config as follow:

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

That file also copied to web.config when publish. In short, the wcf service itself works good.

The problem is this: I make another project which need to discover wcf service on network. But the discovery only works AFTER first calling or navigate manually to the .svc in the browser. When I restart the IIS or wcf in IIS7 manager, discovery back to failed/no any response received. It seems the wcf is not automatically started. I check on IIS config it start automatically. The site itself also set to start automatically. I even put some of these line in applicationHost.config base on some receommendation on the web:

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

Still didn't work! IIS said it 'Started', Site said it 'Started', but discovery still only works after when the service .svc file called manually in the browser. When you restart the server or site, it backs to not work. I believe any service SHOULD be start when IIS start, but it won't.

I found on the internet some others have same problem and still no resolve.

I give up and skip all the confusing and install the initialization page extension for IIS, described by the great Schwammy in this page:

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

It works great, simple!

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