你好
我写了 WCF duplex service 。此服务在 Visual Studio 中运行良好,但是当我发布此服务并将其放在 IIS 上时, Service don't answer to any Client
所有客户端都正确连接到此服务。他们也调用 Service Well 并且没有异常发生。
这些服务(IIS 服务和 VS 托管服务)的唯一区别在于它们的地址。例如 :
* IIS 服务地址是 http://localhost/SmsService/SmsService.svc 或者更好的说法是虚拟路径地址。
* VS 托管服务地址是 http://localhost:1408/SmsSrevice.svc
绝对I changed Server address for client's.
这里是服务/应用程序配置:
VS 托管服务

<system.serviceModel>
<services>
  <service name="SmsService.Business.SmsService"
           behaviorConfiguration="ServiceBehavior">
    <endpoint address="http://localhost:1408/SmsService.svc"
              binding="wsDualHttpBinding"
              contract="SmsService.Business.ISmsService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

IIS 托管服务
    <system.serviceModel>
<services>
  <service name="SmsService.Business.SmsService"
           behaviorConfiguration="ServiceBehavior">
    <endpoint address=""
              binding="wsDualHttpBinding"
              contract="SmsService.Business.ISmsService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

客户端配置
  <system.serviceModel>
<bindings>
  <wsDualHttpBinding>
    <binding name="WSDualHttpBinding_SMSService"
             closeTimeout="00:10:00"
             clientBaseAddress="http://MyMachinName:10300/SmsClientService"
             openTimeout="00:01:00"
             receiveTimeout="00:10:00"
             sendTimeout="00:10:00"
             bypassProxyOnLocal="false"
             transactionFlow="false"
             hostNameComparisonMode="StrongWildcard"
             maxBufferPoolSize="524288"
             maxReceivedMessageSize="65536"
             messageEncoding="Text"
             textEncoding="utf-8" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32"
                    maxStringContentLength="8192"
                    maxArrayLength="16384"
                    maxBytesPerRead="4096"
                    maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" />
      <security mode="Message">
        <message clientCredentialType="Windows"
                 negotiateServiceCredential="true"
                 algorithmSuite="Default" />
      </security>
    </binding>
  </wsDualHttpBinding>
</bindings>
<client>
  <endpoint address="http://SERVER1/SmsService/SmsService.svc"
            binding="wsDualHttpBinding"
            bindingConfiguration="WSDualHttpBinding_SMSService"
            contract="ServiceReference.SMSService"
            name="WSDualHttpBinding_SMSService">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</client>

甚至我在服务方法的第一个中编写了事件日志,但这不起作用!



编辑 1

首先谢谢大家

其次,我认为,我没有清楚地解释我的问题。 “此服务在 Visual Studio 中运行良好”是指在 VS 中我可以通过客户端与服务器通信(在 VS 中与服务相同的解决方案上)。客户端可以调用服务,服务也可以调用客户端,并且工作正常(任何计算、回调、数据库操作等)

但是,当我将在 VS 中自己正常工作的服务发布到无法正常工作的 IIS 中时(即使在我自己的计算机中)。这意味着 Client can create service object and connect to that IIS Hosted Service ,但是当客户端的调用服务没有 event(calculation, callback's, database-actions) 和 Service also don't call Client's

我不明白,如果我的代码的任何步骤有错误,必须在 VS 的运行时发生。所以一定是我错过的东西,比如 security config, client side config or something else

最佳答案

可能是防火墙阻止了端口 1408

关于c# - WCF 和 IIS 中的神秘问题?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4265033/

10-16 16:42