簡體   English   中英

從IIS中托管的ASP.NET Web應用接收WCF回調服務

[英]Receiving a WCF callback service from a ASP.NET web app hosted in IIS

我已經在這個問題上工作了幾天。

該問題有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中托管時卻不能正常運行。

答案較晚,但以防萬一像我這樣的人通過Big G提出了這個問題。

我有類似的問題,對我來說解決方案是將CallbackBehavior添加到實現回調接口的類(在您的情況下為IClientCallback)。 像這樣:

[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
public class ClientCallback : IClientCallback
...

希望能有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM