我已经在这个问题上工作了几天了。
问题有 3 个工作部分。我有一个 ASP.NET 站点、WCF IIS 托管服务和 WPF xbap 应用程序。
我想要做的是将变量从 ASP.NET 站点传递到 WPF xbap 应用程序。所以我设置了一个带有 wsDualHttpBinding 的 WCF 服务,并使用回调来通知 ASP.NET 和 xbap。
现在,当我在我们的服务器上的 IIS 6 中托管 WCF 服务并在本地运行 VS2012 iisexpress 和本地 xbap 中的 ASP.NET 托管时。它工作正常。但是,一旦我将 ASP.NET 站点发布到我们服务器上的 IIS 6,ASP.NET 应用程序就永远不会收到回调。两者都在应用程序池中。
是否有设置,或者我需要寻找什么让 ASP.NET 保持打开回调的侦听端口?XBAP 仍在接收回调,没问题。
服务配置如下:(请注意,由于目前的简单性,我已将缓冲区最大化以排除这种情况)
<configuration>
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="web_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding receiveTimeout="00:01:00" sendTimeout="00:00:05" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"
multipleSiteBindingsEnabled="false" />
<protocolMapping>
<add scheme="http" binding="wsDualHttpBinding" />
</protocolMapping>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
该服务具有客户端将订阅回调列表的方法。然后方法将通过列表递增以发送调用回调。
[ServiceContract(CallbackContract = typeof(IClientCallback))]
public interface IVisualisationService
{
[OperationContract(IsOneWay = true)]
void SubscribeToRedenderHoles(string address);
[OperationContract(IsOneWay = true)]
void SubscribeToEditSelectedHoles(string address);
[OperationContract(IsOneWay = true)]
void SubscribeToShowHoles(string address);
[OperationContract(IsOneWay = true)]
void RedenderHoles(Hole3D[] holes, string address, int channelhashcode);
[OperationContract(IsOneWay = true)]
void EditSelectedHoles(Guid[] holesIds, string address);
[OperationContract(IsOneWay = true)]
void ShowHoles(string address);
}
public interface IClientCallback
{
[OperationContract(IsOneWay = true)]
void OnRenderHoles(Hole3D[] holes);
[OperationContract(IsOneWay = true)]
void OnEditSelectedHoles(Guid[] holesIds);
[OperationContract(IsOneWay = true)]
void OnShowHoles(int channelhashcode);
}
下面是 WCF 服务标头,我跳过了方法。
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class VisualisationService : IVisualisationService
{
现在为 ASP.NET 客户端 web.config
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IVisualisationService" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://hims.mecha.com/VisualisationWcfService/VisualisationService.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IVisualisationService"
contract="VisualisationServiceReference.IVisualisationService"
name="WSDualHttpBinding_IVisualisationService" />
</client>
</system.serviceModel>
然后是 XBAP 应用客户端 app.config
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IVisualisationService" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://hims.mecha.com/VisualisationWcfService/VisualisationService.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IVisualisationService"
contract="VisualisationService.IVisualisationService" name="WSDualHttpBinding_IVisualisationService" />
</client>
</system.serviceModel>
</configuration>
在这两个客户端中,我都使用了添加服务引用方法,将 WCF 添加到 ASP.NET 和 XBAP 项目中。我已经将两个客户端都设置为拥有代码,当然还可以处理每个回调的方法。
sealed class VisualisationManager : VisualisationService.IVisualisationServiceCallback
我知道它看起来有点啰嗦,但我想尽可能多地展示这个问题。我完全迷失了,为什么它在本地可以正常工作,但在 IIS 6 中托管时却不行。