我无法使用WSHttpBinding在IIS上部署我的WCF服务

时间:2015-11-11 19:49:21

标签: c# wcf iis deployment

我真的需要帮助。 我试图部署一个我在过去一个月里一直在努力的.NET WCF应用程序。

我使用IIS 7作为我的WCF主机,并使用wsHTTPBinding,因为我需要使用Session对象来存储凭据。我的客户端是一个使用MVVM模式和Caliburn.Micro的WPF应用程序。

到目前为止,我管理(我认为)在IIS上成功创建服务。 如果我浏览" http://localhost/Ohmio/OhmioService.svc" ,我会看到"您创建服务"信息。但是,当我运行我的客户端并尝试连接到它时,我的应用程序关闭并出现错误"应用程序已停止工作..." bla bla bla。

这是我的服务器Web.Config:

<?xml version="1.0"?>
<configuration>
  <appSettings/>
    <system.web>
    <compilation targetFramework="4.0"/>    
    <authentication mode="Windows"/>    
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.webServer>    
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>      
        <binding name="myBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">         
          <readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
      <security mode="None" />
      <reliableSession enabled="true" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WcfService1.Service1Behavior" name="WcfService1.OhmioSVC">    
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="myBinding" contract="WcfService1.IOhmioSVC" >          
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService1.Service1Behavior">          
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

这是客户端App.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IOhmioSVC" maxReceivedMessageSize="20000000"/>
        <security mode="None" />
            <reliableSession enabled="true" />
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost/Ohmio/OhmioService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IOhmioSVC" contract="OhmioSVC.IOhmioSVC" name="WSHttpBinding_IOhmioSVC">
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

我的应用程序在我的开发机器上工作正常。 请帮忙!我甚至不知道从哪里开始寻找原因。

谢谢!

修改

确定。我按照建议放置了Try catch,错误如下:

  

例外:由于与远程端点的安全协商,无法打开安全通道。

内部异常:

  

此端点不接受操作...并且只接受进程WSReliableMessaging

2 个答案:

答案 0 :(得分:0)

我认为这与此相同:

How to configure WCF Service with wsHttpBinding hosted on IIS and consumable over Web?

但我没有这样的声誉。

答案 1 :(得分:0)

我认为问题与可靠的会话有关(不是100%肯定,但我的神经告诉我)。我发现了一些可能对implementation可靠会话有帮助的文章。

希望这会对你有所帮助:)。

相关问题