我已经在这个问题上工作了几天了。
问题有三个工作部分。我有ASP。. NET网站、WCF IIS托管服务和WPF xbap应用。
我要做的是从ASP传递变量。所以我用wsDualHttpBinding设置了一个WCF服务,并使用回调来通知ASP。. NET和xbap.
现在,当我在IIS 6中托管WCF服务时,在我们的服务器上运行ASP。. NET托管在VS2012本地和xbap本地。它工作得很好。但是一旦我发布ASP。. NET站点到我们服务器上的iis6,回调永远不会被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 Client 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 client 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中托管时却不行。
迟到了,但如果有人像我一样通过Big g来解决这个问题
我有类似的问题,我的解决方案是添加一个CallbackBehavior类实现回调接口(在你的情况下;IClientCallback)。这样的:
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
public class ClientCallback : IClientCallback
...