【问题标题】:Message could not be Processed exception in WCFWCF 中的消息无法处理异常
【发布时间】:2012-07-02 13:19:52
【问题描述】:

您好,我正在尝试在我的 Windows 应用程序中调用 WCF 服务

我将服务引用添加到我的项目中,但在执行时出现以下错误:

这很可能是因为该操作 'http://tempuri.org/IUser/SaveUser' 不正确或因为 消息包含无效或过期的安全上下文令牌或 因为绑定之间存在不匹配。安全上下文 如果服务因以下原因中止通道,则令牌将无效 不活动。防止服务中止空闲会话 过早地增加服务端点的接收超时 绑定。

我尝试增加服务端点绑定的接收超时。但也有同样的例外。

这里是config file on client

<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IUser" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:30:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:45:00"
                        enabled="false" />
                  <security mode="None">
                    <transport clientCredentialType="None" />
                  </security>

                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://t2.ipixsolutions.net/Service.svc" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_IUser" contract="ServiceReference1.IUser"
                name="WSHttpBinding_IUser">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

在服务器上配置

<system.serviceModel>
        <services>
      <service behaviorConfiguration="ServiceBehavior" name="WCFLibrary.Users">
                <endpoint address="" binding="wsHttpBinding" contract="WCFLibrary.IUser">
          <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                    <serviceMetadata httpGetEnabled="true"/>
                    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

【问题讨论】:

  • 将绑定设置与服务器上的设置进行比较。正如错误中提到的那样,其中很可能存在不匹配。
  • 或者更好的是,在这里发布它们。
  • 请您发布完整的例外情况。
  • 可能是主机。尝试使用 localhost 而不是 tempuri.org
  • @thecoon 请检查我的编辑。在服务器和客户端都添加了配置文件

标签: c# .net wcf service


【解决方案1】:

嘿,我也遇到了同样的异常,在我的情况下,这是因为这个设置:

<security mode="None">

如果我将其更改为:

<security mode="Message">

它工作正常。我想它必须从默认值中提取,因为我没有在服务器端设置它。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,并使用以下内容修改了安全元素

                    <security mode="Message">
                        <transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm"
                            realm=""  />
                        <message clientCredentialType="Windows" algorithmSuite="Default" />
                    </security>
    
    1. 我将安全模式从“无”修改为“消息”。
    2. 我将传输的 ClientCredentialType 从“None”修改为“Ntlm”= clientCredentialType="Ntlm"
    3. 我将 Transport 的 proxyCredentialType 从“None”修改为“Ntlm”= proxyCredentialType ="Ntlm"

    【讨论】:

      【解决方案3】:

      也许这会对某人有所帮助。我在客户的 PC 上弹出了同样的错误。该应用程序在 10 次中有 9 次无法登录到我们的服务器。这适用于曾经完美运行的 WCF 客户端。罪魁祸首原来是一个广告软件应用程序,他一定是不小心安装了另一个软件。它将添加添加到 http 流中,这会破坏我们的通信。有问题的广告软件是 RocketTab (http://malwaretips.com/blogs/rockettab-virus-removal/)。

      我们发现问题的方法是注意到如果我们在他的 PC 上使用不同的 Windows 用户,问题就不会发生。然后,我们使用任务管理器关闭了他 PC 上看起来并不重要的进程,并发现当我们关闭 client.exe 进程时,我们的应用程序开始工作。这导致我们使用 RocketTab(他们的可执行文件是 client.exe)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-08-23
        • 2011-09-16
        • 2011-04-28
        • 1970-01-01
        • 2013-07-02
        • 2013-07-19
        相关资源
        最近更新 更多