简体   繁体   中英

Configuring WCF client gives the error "The message could not be processed. This is most likely because the action

My web service returns a error message no matter what configurations I set. I get the following error message.

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.

Here are my server & client web.config sections for WCF.

Server:

<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>

Client:

<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>

You most likely have a service contract mismatch on the ITestingWebService interface. Try running a "Update Service Reference" by right clicking on the service reference in Visual Studio and see if that fixes the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM