C#:Bug,EndpointDispatcher&ContractFilter

來源:互聯網
上載者:User

標籤:c#   bug   

項目發布的時候,檔案上傳忽然出現一個問題,很古怪,問題描述如下:

Error:

StackTrace:

 

[FaultException:由於  ContractFilter在 EndpointDispatcher不匹配,因此 Action為“http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue”的訊息無法在接收方處理。這可能是由於協定不匹配(發送方和接收方 Action 不匹配)或發送方和接收方綁定/安全不匹配。請檢查發送方和接收方是否具有相同的協定和綁定(包括安全要求,如 Message、Transport、None)。]

   System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(Message message, EndpointAddress target) +5499790

   System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState) +49

 

[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. ]

   WHPT_WebApp.HanderOperater.HanderOperaterAddMuti.btn_import_Click(Object sender, ImageClickEventArgs e) in E:\GH_WHPT1210\WHPT_WebApp\HanderOperater\HanderOperaterAddMuti.aspx.cs:163

   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115

   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +120

   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10

   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13

   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36

   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

[SecurityNegotiationException:無法開啟安全通道,因為安全協商與遠程終結點失敗。這可能是由於缺席或不正確地指定的EndpointIdentity在EndpointAddress用來建立的通道。請驗證EndpointIdentity指定或隱含的EndpointAddress正確標識遠程終結點。]


屬性值

類型:System.Boolean
如果通過協商過程擷取服務憑據,則為 true;否則為false。預設值為 true。


MessageSecurityOverHttp.NegotiateServiceCredential 屬性

NegotiateServiceCredential ="true"

擷取或設定一個值,該值指示是在帶外用戶端提供服務憑據,還是通過協商過程從服務向用戶端擷取服務憑據。


屬性設定為 true 需要用戶端和服務支援 WS-Trust 和 WS-SecureConversation。將屬性設定為false 時不需要 WS-Trust 或 WS-SecureConversation 受支援。

對於 Anonymous、Username 或 Certificate 用戶端憑據類型,將此屬性設定為false 意味著服務憑證必須可用於帶外用戶端,並且用戶端必須指定要使用的服務憑證。

對於 Windows 憑據,將此屬性設定為 false 將導致基於KerberosToken 的身分識別驗證。這要求用戶端和服務都是 Kerberos 域的一部分。 此模式可與實現 OASIS Kerberos 令牌設定檔的 SOAP 堆棧互動操作。將此屬性為true 會引起通過 SOAP 訊息進行 SPNego 交換的 SOAP 協商。此模式不可互操作。

此屬性指示是否在用戶端和服務之間自動協商服務憑據。 如果此屬性為 true,則會進行此類協商。 如果此屬性為 false,則在與服務進行通訊之前,必須在用戶端指定服務憑據。

如果將此屬性設定為 false,並且將綁定配置為使用 Windows 作為用戶端憑據類型,則必須將服務帳戶與服務主體名稱 (SPN) 相關聯。為此,請在 NETWORK SERVICE 帳戶或 LOCAL SYSTEM 帳戶下運行服務。也可以使用 SetSpn.exe 工具為服務帳戶建立一個 SPN。 不論何種情況,用戶端都必須使用 <servicePrincipalName> 元素中的正確 SPN,或者通過使用EndpointAddress 建構函式來應用正確的 SPN。

WSHttpBinding binding = new WSHttpBinding();binding.Security.Mode = SecurityMode.Message;binding.Security.Message.ClientCredentialType =    MessageCredentialType.UserName;binding.Security.Message.NegotiateServiceCredential = false;CalculatorClient CalculatorClient = new CalculatorClient("myBinding");CalculatorClient.ClientCredentials.ServiceCertificate.    SetDefaultCertificate("Al", StoreLocation.CurrentUser, StoreName.My);

另外,發一下我的配置錯誤所在:

 <configuration>                                                                                                                  <system.serviceModel>    <bindings>      <wsHttpBinding>        <binding name="WSHttpBinding_IExcelService" 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" />          </security>        </binding>      </wsHttpBinding>    </bindings>    <client>      <endpoint address="http://localhost/ExcelService.svc" binding="wsHttpBinding"      bindingConfiguration="WSHttpBinding_IExcelService" contract="ExcelService.IExcelService"      name="WSHttpBinding_IExcelService">        <identity>          <dns value="localhost" />        </identity>      </endpoint>    </client>  </system.serviceModel></configuration>

PS:此文僅供記錄交流,不做它用






C#:Bug,EndpointDispatcher&ContractFilter

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.