.net - 配置 WCF 客户端出现错误“无法处理消息。这很可能是因为操作

标签 .net wcf configuration client

无论我设置什么配置,我的网络服务都会返回一条错误消息。我收到以下错误消息。

The message could not be processed. This is most likely because the action 'http://tempuri.org/ITestingWebService/DoWork' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.

这是我的 WCF 服务器和客户端 web.config 部分。

服务器:

<system.serviceModel>
   <behaviors>
      <serviceBehaviors>
         <behavior name="ConnectedStoreCCM.TestingWebServiceBehavior">
            <serviceMetadata httpGetEnabled="true"  httpGetUrl="" />
            <serviceDebug includeExceptionDetailInFaults="true"  />
         </behavior>
      </serviceBehaviors>
   </behaviors>
   <bindings>
      <wsHttpBinding>
         <binding name="WSHttpBinding_ITestingWebService" 
             openTimeout="00:01:00" receiveTimeout="00:10:00"
             sendTimeout="00:10:00" bypassProxyOnLocal="false"
             transactionFlow="false" hostNameComparisonMode="StrongWildcard"
             messageEncoding="Text" textEncoding="utf-8"
             useDefaultWebProxy="true" allowCookies="false"
             maxReceivedMessageSize="2097152" maxBufferPoolSize="1024768">
            <readerQuotas 
                maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
            <security mode="None">
               <transport clientCredentialType="None" />
               <message clientCredentialType="None" negotiateServiceCredential="false" 
                        establishSecurityContext="false" />
            </security>
         </binding>
      </wsHttpBinding>
   </bindings>
   <services>
       <service behaviorConfiguration="ConnectedStoreCCM.TestingWebServiceBehavior"
                name="ConnectedStoreCCM.TestingWebService">
          <endpoint 
              address="" 
              binding="wsHttpBinding" 
              contract="ConnectedStoreCCM.ITestingWebService">
             <identity>
                <dns value="localhost" />
             </identity>
          </endpoint>
          <endpoint 
              address="mex" 
              binding="mexHttpBinding" 
              contract="IMetadataExchange" />
          <host>
             <baseAddresses>
                <add baseAddress="http://www.someuri.net/supertest/TestingWebService.svc?wsdl" />
             </baseAddresses>
          </host>
       </service>
    </services>
</system.serviceModel>

客户:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_ITestingWebService" closeTimeout="00:10:00" openTimeout="00:10:00"
             receiveTimeout="00:10:00" sendTimeout="00:10:00"
             bypassProxyOnLocal="false" transactionFlow="false"
             hostNameComparisonMode="StrongWildcard"
             messageEncoding="Text" textEncoding="utf-8"
             useDefaultWebProxy="true" allowCookies="false"
             maxBufferPoolSize="1024768"
             maxReceivedMessageSize="2097152" >
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="None">
            <transport clientCredentialType="None" />
            <message clientCredentialType="None" negotiateServiceCredential="false" establishSecurityContext="false" />
          </security>
        </binding>
      </wsHttpBinding>
   </bindings>
   <client>
      <endpoint name="WSHttpBinding_ITestingWebService" 
           address="http://www.someuri.net/supertest/TestingWebService.svc?wsdl"
           binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITestingWebService"
           contract="ServiceReference1.ITestingWebService" >
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
   </client>
</system.serviceModel>

最佳答案

您很可能在 ITestingWebService 接口(interface)上有不匹配的服务契约(Contract)。尝试通过右键单击 Visual Studio 中的服务引用来运行“更新服务引用”,看看是否可以解决问题。

关于.net - 配置 WCF 客户端出现错误“无法处理消息。这很可能是因为操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10144348/

相关文章:

c# - 为什么 Span<T> 扩展方法未使用 'in' 参数修饰符实现?

c# - 在 Azure 实例上实现简单的本地内存缓存

configuration - 是否可以为每个网站而不是全局设置 Piwik 的“请勿跟踪”功能?

java - Guice 和一般应用程序配置

c# - 如何从对象列表中删除(通过 linq)重复项

c# - C# 4.0 中 "dynamic"变量的实际用途是什么?

c# - WCF - 传输安全是否仅适用于 Intranet 方案?

JQuery Json错误: Object doesn't support this property or method

c# - 如何在已安装的服务上授予对 HTTP 命名空间的权限?

configuration - gpg2 : How to use another secret and public keyring?