我(尝试)在“服务器”计算机上的IIS中托管WCF服务,并从单独的“客户端”计算机访问它。一切都在开发环境中运行良好,但在移动到生产机器时出现故障。
客户端收到错误: System.ServiceModel.ServiceActivationException:请求的服务,
无法激活。见 服务器的诊断跟踪日志以获取更多信息。
设法在我的Web服务器上配置跟踪,错误日志显示:
Description: Failed to open System.ServiceModel.ServiceHost
Level: Warning
Process Name: w3wp
Trace Identifier: http://msdn.microsoft.com/en-US/library/System.ServiceModel.CommunicationObjectOpenFailed.aspx
Activity Name: Open ServiceHost 'Nova.ClientProxy.NovaDataService
Source: System.ServiceModel
我知道服务器存在问题,但我似乎无法解决这个问题。任何帮助都真的 非常赞赏! (我确信这里有很多不需要的东西,但我在这里是一个完整的新手。)谢谢!
以下是配置文件:
项目c:\ nova5 \ WebSite \有Nova.svc:
<%@ ServiceHost Language="C#" Debug="true" Service="Nova.ClientProxy.NovaDataService" %>
和Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Nova.ClientProxy.NovaDataService">
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<diagnostics>
<messageLogging
logMessagesAtTransportLevel="true"
logMessagesAtServiceLevel="false"
logMalformedMessages="true"
logEntireMessage="true"
maxSizeOfMessageToLog="65535000"
maxMessagesToLog="500" />
</diagnostics>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="myUserTraceSource"
switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="Error.svclog" />
</sharedListeners>
</system.diagnostics>
在项目Nova.ClientProxy中,App.config文件为:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<services>
<service name="Nova5.UI.DataServiceLibrary.NovaDataService">
<endpoint address="" binding="wsHttpBinding" contract="Nova5.UI.DataServiceLibrary.INovaDataService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/Nova5.UI.DataServiceLibrary/Service1/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<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="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>