1

私はこの問題に数日間取り組んできました。

問題には 3 つの作業部分があります。ASP.NET サイト、WCF IIS ホステッド サービス、および WPF xbap アプリがあります。

私がやろうとしているのは、変数を ASP.NET サイトから WPF xbap アプリに渡すことです。そのため、wsDualHttpBinding を使用して WCF サービスをセットアップし、コールバックを使用して ASP.NET と xbap に通知しました。

サーバーのIIS 6でWCFサービスをホストし、VS2012でASP.NETホスティングを実行すると、ローカルでiisexpressとxbapがローカルで実行されます。それは正常に動作します。しかし、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>

両方のクライアントで、Add Service Reference メソッドを使用して、WCF を ASP.NET プロジェクトと XBAP プロジェクトの両方に追加しました。私は両方のクライアントにコードを持たせ、もちろん各コールバックのメソッドを処理するようにセットアップしました。

sealed class VisualisationManager : VisualisationService.IVisualisationServiceCallback

少し長くなってしまったように見えますが、この問題についてできる限り多くのことを示したかったのです。IIS 6でホストされている場合はローカルでは正常に機能するのに、なぜ機能しないのか、私は完全に迷っています。

4

1 に答える 1

0

遅い答えですが、ビッグGを通じてこの質問にたどり着いた私のような誰かの場合.

同様の問題がありましたが、私にとっての解決策は、コールバック インターフェイスを実装するクラスに CallbackBehavior を追加することです (この場合は IClientCallback)。このような:

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

この助けを願っています。

于 2013-11-21T09:17:06.573 に答える