【发布时间】:2012-12-12 15:10:35
【问题描述】:
我看到网上有几个类似的主题,所以关于这个,但没有一个对我解决这个问题有帮助。
我有一个 wcf 服务,它由 IIS 中的同一个 Web 应用程序托管和使用(不要问为什么)。 所以我的 web.config 看起来像这样
<system.serviceModel>
<services>
<service name="Management.Service.ManagementService" behaviorConfiguration="Management.Service.ManagementServiceBehavior">
<endpoint name="default" binding="basicHttpBinding" bindingConfiguration="default" contract="Management.Service.IManagementService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Management.Service.ManagementServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<bindings>
<basicHttpBinding>
<binding name="default" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="true" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.example.com/Service.svc"
binding="basicHttpBinding" bindingConfiguration="default"
contract="Management.Client.IManagementService" name="default" />
</client>
</system.serviceModel>
这在我的本地环境中工作得非常好,我什至可以在任何浏览器中浏览到服务(生产)。但是由于某种原因,我在生产服务器上收到 There was no endpoint listening 错误。
我还尝试在<system.serviceModel> 标记后添加以下块以启用跟踪,但我没有看到正在生成任何跟踪文件。
<system.diagnostics>
<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>
</sources>
<sharedListeners>
<add initializeData="C:\inetpub\WcfClient.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="xml"/>
</sharedListeners>
</system.diagnostics>
编辑:忘了说,如果我尝试从本地环境使用生产服务,它工作正常!
【问题讨论】:
-
为什么将服务和消费者托管在同一个进程中?这是零意义。
-
@hugh - 好的,这就是为什么 - 我有同一个 Web 应用程序的多个实例,它们服务于不同的组织。有问题的服务公开了它运行的实例的某些数据(这些数据可能因实例而异)。每个实例都知道在其他实例中运行的其他服务(服务的 url 存储在数据库中)。 Web应用程序中有一个特定的模块,它基本上从它知道的所有服务中获取数据并显示它。所以基本上目的是显示相关组织的数据。
-
所以您的每个服务都在不同的 w3wp.exe 实例中运行?而且每个 Web 应用的客户端也只是调用运行在不同 w3wp 进程中的服务?
-
@hugh 是的。每个 Web 应用程序都有自己运行的服务。每个 Web 应用程序都可以了解 1 个或多个其他服务并从中获取数据。
标签: wcf