gpt4 book ai didi

WCF 服务 SecurityNegotiationException

转载 作者:行者123 更新时间:2023-12-04 05:35:11 29 4
gpt4 key购买 nike

我正在使用 WCF 在我的服务器上运行一个简单的服务;该服务托管在 WebDev.WebServer.exe(本地)中。

当我调用本地服务时,出现以下异常:

Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint. ---> System.ServiceModel.FaultException: The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).



这是我来自客户端和服务器的两个 app.config 文件。我使用 svcutil-Tool 从客户端制作了 app.config 所以它应该是正确的:

客户
<client>
<endpoint address="http://localhost:1634/UsuarioContexto.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUsuarioContexto"

contract="CarWin.ServiceContracts.Interfaces.IUsuarioContexto" name="LOCAL_WSHttpBinding_IUsuarioContexto">

<identity><dns value="localhost" /></identity>

</endpoint>

</client>

<binding name="WSHttpBinding_IUsuarioContexto" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10: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:10:00" enabled="false" />

<security mode="Message">

<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />

<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />

</security>

</binding>

服务器
<services>
<service behaviorConfiguration="UsuarioContextoBehavior" name="UserContext.Host.UsuarioContexto">

<endpoint address="" binding="wsHttpBinding" bindingNamespace="http://CarWin" bindingConfiguration="wsHttpBinding_IUsuarioContexto"

contract="CarWin.ServiceContracts.Interfaces.IUsuarioContexto">

<identity>

<dns value="localhost" />

</identity>

</endpoint>

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>

</services>


<bindings>

<wsHttpBinding>

<binding name="wsHttpBinding_IUsuarioContexto" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">

<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" />

<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />

<security mode="None">

<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />

<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />

</security>

</binding>

</wsHttpBinding>

</bindings>

<behaviors>

<serviceBehaviors>

<behavior name="UsuarioContextoBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

最佳答案

问题出在服务器上,我放置了 mode="Message"并且运行良好。谢谢。

<security mode="None">  

<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />

<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />

</security>

关于WCF 服务 SecurityNegotiationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2146189/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com