简体   繁体   English

从IIS中托管的ASP.NET Web应用接收WCF回调服务

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

I have been working on this issue for a couple of days now. 我已经在这个问题上工作了几天。

The problem has 3 working parts. 该问题有3个工作部分。 I have a ASP.NET site , WCF IIS hosted service and WPF xbap app. 我有一个ASP.NET网站,WCF IIS托管服务和WPF xbap应用程序。

What I'm trying to do is pass variables from the ASP.NET site to the WPF xbap app. 我想做的是将变量从ASP.NET站点传递到WPF xbap应用程序。 So I have setup a WCF service with a wsDualHttpBinding and using callbacks to notify the ASP.NET and the xbap. 因此,我使用wsDualHttpBinding设置了WCF服务,并使用回调通知ASP.NET和xbap。

Now when I host the WCF service in IIS 6 on our server and run ASP.NET hosting in VS2012 iisexpress locally and xbap locally. 现在,当我在服务器上的IIS 6中托管WCF服务并在VS2012 iisexpress本地和xbap本地中运行ASP.NET托管时。 It works fine. 工作正常。 But as soon as I publish the ASP.NET site to the IIS 6 on our server, callback are never received by the ASP.NET app. 但是,一旦我将ASP.NET站点发布到服务器上的IIS 6,ASP.NET应用程序就不会收到回调。 Both are in the application pool. 两者都在应用程序池中。

Is there a setting, or something I need to be looking for to have the ASP.NET to keep open the listening port for the callbacks? 是否有设置,或者我需要寻找什么使ASP.NET保持打开回调的侦听端口? The XBAP is still receiving the callbacks, no problem. XBAP仍在接收回调,没问题。

The service config is as follows: (note I have maxed out the buffers because of simplicity for the moment to rule that out) 服务配置如下:(请注意,由于暂时的原因,我已经简化了缓冲区的使用,从而使缓冲区最大化)

<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>

The service has methods where clients will subscribe to callback lists. 该服务具有客户端将订阅回调列表的方法。 Then methods will increment through the list to send the invoke the callbacks. 然后,方法将在列表中递增以发送调用的回调。

[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);
}

Below is the WCF Service header, Ive skipped putting in the methods. 下面是WCF服务标头,我已经跳过了放入方法的过程。

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class VisualisationService : IVisualisationService
{

Now for the ASP.NET Client web.config 现在用于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>

Then XBAP app client app.config 然后,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>

In both clients I have used the Add Service Reference method, to add the WCF to both the ASP.NET and XBAP projects. 在这两个客户端中,我都使用“添加服务引用”方法将WCF添加到ASP.NET和XBAP项目中。 I have setup both clients to have the code and of course handle the methods for each callback. 我已经设置了两个客户端都具有代码,并且当然处理每个回调的方法。

sealed class VisualisationManager : VisualisationService.IVisualisationServiceCallback

I know it looks a bit long winded, but I wanted to show as much about the problem as I could. 我知道它看起来有些长,但是我想尽可能多地展示这个问题。 I am completely lost, why it would work fine locally but not when hosted in IIS 6. 我完全迷失了,为什么它在本地可以正常运行,但是在IIS 6中托管时却不能正常运行。

late answer but in case someone like me who get to this question through the Big G. 答案较晚,但以防万一像我这样的人通过Big G提出了这个问题。

I had similar issue and the solution for me is to add a CallbackBehavior to the class which implement the callback interface (in your case; IClientCallback). 我有类似的问题,对我来说解决方案是将CallbackBehavior添加到实现回调接口的类(在您的情况下为IClientCallback)。 like this: 像这样:

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

Hope this help. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何处理ASP.NET网页和IIS中托管的WCF服务之间的跨域请求? - How to handle cross domain request between an asp.net web page and a WCF service hosted in IIS? ASP.NET ExecutionTimeout对IIS托管的WCF服务无效 - ASP.NET ExecutionTimeout no effect on IIS-hosted WCF service 调试IIS中托管的asp.net WCF服务 - debugging asp.net WCF service hosted in IIS 如何从Asp.net 2.0使用IIS托管的WCF服务 - How to Comsume IIS Hosted WCF Service from Asp.net 2.0 在iis上从asp.net web app调用windows服务 - Invoke windows service from asp.net web app on iis Windows服务中托管的WCF可以模拟来自asp.net Web应用程序的域Windows调用者吗? - Can a WCF hosted in windows service impersonate a domain windows caller from asp.net web application? 发布的asp.net Web应用程序和发布的wcf服务无法在IIS中连接 - published asp.net web app and published wcf service not connectiing in IIS 无法从IIS7中托管的ASP.Net Web应用使用Win Auth连接到数据库 - Unable to connect to database using Win Auth on from ASP.Net web app hosted in IIS7 使用WCF服务验证ASP.NET Web应用程序 - Authenticating ASP.NET web app with WCF service 经过一段时间的工作,IIS/ASP.Net 无法从 WCF web 服务的 web.config 文件中读取设置 - After some time of work, IIS/ASP.Net fails to read the settings from the web.config file of WCF web service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM