开发者

WCF app Deployed on Win7 Machine and get connection refused error

开发者 https://www.devze.com 2022-12-27 03:56 出处:网络
I have created a Sync Framework application based on the following sample from microsoft and deployed it to a new Windows 7 machine for testing.The app runs ok but when I attempt to communicate I get

I have created a Sync Framework application based on the following sample from microsoft and deployed it to a new Windows 7 machine for testing. The app runs ok but when I attempt to communicate I get the following error:

Could not connect to http://localhost:8000/RelationalSyncContract/SqlSyncService/. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000.

I am wondering if there is something I am missing. This is my first experience using WCF and followed microsoft sample code.

I have disabled the firewall and opened port 8000 for both TCP and UDP. Not sure what to look at next. Below is my App.config file if this helps:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true"/>
    <httpRuntime maxRequestLength="32768" />
  </system.web>
  <!-- When deploying the开发者_开发技巧 service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="WebSyncContract.SyncServiceBehavior" name="WebSyncContract.SqlWebSyncService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="largeMessageHttpBinding" contract="WebSyncContract.ISqlSyncContract">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/RelationalSyncContract/SqlSyncService/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <!-- We are using Server cert only.-->
        <binding name="largeMessageHttpBinding" maxReceivedMessageSize="204857600">
          <readerQuotas maxArrayLength="1000000"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WebSyncContract.SyncServiceBehavior">
          <!-- 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>
  </system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

Thank you, your help is much appreciated.


Its possible to analyse if the service is starting correctly or not, by enabling Message logging and Trace:

    <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
      <source name="System.ServiceModel" switchValue="Information,ActivityTracing"
        propagateActivity="true">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="Your_svclog_file_here"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
      <add initializeData="Your_svclog_file_here"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>

In this case, the Trace is able to log "Information". Its important to see the channels creation.

To analyse the svclog file, you can use the Service Trace Viewer - Microsoft Windows SDK, usually in C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号