2012-07-02 30 views
2

你好我试图调用WCF服务在我的Windows应用程序消息无法在WCF来处理异常

我添加服务引用到我的项目,但在执行以下错误occures:

这很可能是因为动作 “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> 
+0

将绑定设置与服务器上的绑定设置进行比较。最有可能的是在那里有一个不匹配,正如错误也提到的那样。 –

+0

或者更好,将它们发布到这里。 –

+0

请您发表完整的例外。 –

回答

2

嘿,我得到这个非常相同的异常,在我而言,这是因为此设置:

<security mode="None"> 

如果我将其更改为:

<security mode="Message"> 

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

0

我有同样的问题,并与以下

   <security mode="Message"> 
        <transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" 
         realm="" /> 
        <message clientCredentialType="Windows" algorithmSuite="Default" /> 
       </security> 
  1. 我修改了安全模式从“无”到“信息”修改的安全元素。
  2. 我修改ClientCredentialType从 “无” 到 “NTLM”= clientCredentialType = “NTLM”
  3. 运输我修改proxyCredentialType用于传输从 “无” 到 “NTLM”= proxyCredentialType = “NTLM”
0

也许这将帮助别人。我在客户的PC上弹出同样的错误。该应用程序将无法登录到我们的服务器9次10次。这是一个WCF客户端,曾经工作得很好。罪魁祸首竟然是一个广告软件应用程序,他必须意外安装其他软件。它会将注入添加到http流中,这会破坏我们的沟通。有问题的广告软件是RocketTab(http://malwaretips.com/blogs/rockettab-virus-removal/)。

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