我已经基于following sample from microsoft创建了一个Sync Framework应用程序,并将其部署到新的Windows 7计算机上进行测试。该应用程序运行正常,但当我尝试通信时,我收到以下错误:
无法连接 http://localhost:8000/RelationalSyncContract/SqlSyncService/。 TCP错误代码10061:无连接 可以因为目标而成 机器主动拒绝了 127.0.0.1:8000。
我想知道是否有遗漏的东西。这是我第一次使用WCF并遵循微软示例代码。
我已禁用防火墙并为TCP和UDP打开了端口8000。不知道接下来要看什么。下面是我的App.config文件,如果这有帮助:
<?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>
谢谢,非常感谢您的帮助。
答案 0 :(得分:0)
通过启用消息记录和跟踪,可以分析服务是否正常启动:
<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>
在这种情况下,Trace能够记录“信息”。看到创建频道非常重要。
要分析svclog文件,您可以使用服务跟踪查看器 - Microsoft Windows SDK,通常位于C:\ Program Files \ Microsoft SDKs \ Windows \ v6.0A \ bin \ SvcTraceViewer.exe