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

问题描述 投票:3回答:1

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

邮件无法处理。这很可能是因为“http://tempuri.org/ITestingWebService/DoWork”操作不正确,或者因为邮件包含无效或过期的安全上下文令牌,或者因为绑定之间存在不匹配。如果服务因不活动而中止通道,则安全上下文令牌将无效。要防止服务中止空闲会话,请过早增加服务端点绑定的接收超时。

这是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>
.net wcf configuration client
1个回答
0
投票

您很可能在ITestingWebService界面上有服务合同不匹配。尝试通过右键单击Visual Studio中的服务引用来运行“更新服务引用”,看看是否可以解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.