再会
我想在 Windows 服务中托管 WCF 服务,因此我正在遵循教程:http: //msdn.microsoft.com/en-us/library/ff649818.aspx
在“第 8 步:向客户端添加 WCF 服务引用”期间,我收到以下错误:
- 无法连接到 net.tcp://localhost:100/Triggers。
- 连接尝试持续了 00:00:02.0058550 的时间跨度。
- TCP错误代码10061:无法建立连接,因为目标机器主动拒绝它 127.0.0.1:100
我尝试了以下网站上提到的大多数(如果不是全部)解决方案:http : //social.msdn.microsoft.com/forums/en-US/wcf/thread/58e420e9-43a3-4119-b541-d18158038e36/ 无济于事.
有人可以请对这件事有所了解吗?
以下是WCF 配置文件:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<!-- <add name="ABSAConnectionString" connectionString="Data Source=192.168.0.18;Initial Catalog=ABSA;Integrated Security=False;user=Wimpie;password=menschen;" -->
<!-- Charlene -->
<!--<add name="ABSAConnectionString" connectionString="Data Source=ik-charlene\SQL2008;Initial Catalog=ABSA;Integrated Security=True" providerName="System.Data.SqlClient" />-->
<add name="ABSAConnectionString" connectionString="Data Source=.\;Initial Catalog=ABSANICO;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms"/>
<authorization>
<!--<deny users="?"/>-->
<allow users="?"/>
</authorization>
<membership defaultProvider="Membership">
<providers>
<clear/>
<add name="Membership" type="ABSAService.Membership"/>
</providers>
</membership>
</system.web>
<system.serviceModel>
<services>
<service name="ABSAService.Triggers" behaviorConfiguration="ABSAService.TriggersBehavior" >
<endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="ABSAService.ITriggers">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:100/Triggers" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ABSAService.TriggersBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
<source name="CardSpace">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.IO.Log">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.Runtime.Serialization">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.IdentityModel">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
<listeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\logs\UserTraces.svclog" />
</listeners>
</source>
</sources>
<trace autoflush="true" />
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\log\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
</configuration>
接下来是Windows 服务配置文件(根据教程与上面相同):
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<!-- <add name="ABSAConnectionString" connectionString="Data Source=192.168.0.18;Initial Catalog=ABSA;Integrated Security=False;user=Wimpie;password=menschen;" -->
<!-- Charlene -->
<!--<add name="ABSAConnectionString" connectionString="Data Source=ik-charlene\SQL2008;Initial Catalog=ABSA;Integrated Security=True" providerName="System.Data.SqlClient" />-->
<add name="ABSAConnectionString" connectionString="Data Source=.\;Initial Catalog=ABSANICO;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms"/>
<authorization>
<!--<deny users="?"/>-->
<allow users="?"/>
</authorization>
<membership defaultProvider="Membership">
<providers>
<clear/>
<add name="Membership" type="ABSAService.Membership"/>
</providers>
</membership>
</system.web>
<system.serviceModel>
<services>
<service name="ABSAService.Triggers" behaviorConfiguration="ABSAService.TriggersBehavior" >
<endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="ABSAService.ITriggers">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:100/Triggers" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ABSAService.TriggersBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>