簡體   English   中英

在C#中創建自定義綁定

[英]Creating a Custom Binding in C#

我一直在嘗試創建一個自定義綁定來輸出這種類型的標題XML:

<soapenv:Header>
  <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
     <wsse:UsernameToken wsu:Id="UsernameToken-BEC9D84D8B68A3118D14543420311491">
        <wsse:Username>user</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pass</wsse:Password>
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">hBcjVXk/NxiSiva5xXKphA==</wsse:Nonce>
        <wsu:Created>2016-02-01T15:53:51.146Z</wsu:Created>
     </wsse:UsernameToken>
  </wsse:Security>

到目前為止,這是我的代碼:

        var customBinding= new CustomBinding();

        var securityBindingElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
        securityBindingElement.IncludeTimestamp = false;
        customBinding.Elements.Add(securityBindingElement);
        customBinding.Elements.Add(new TextMessageEncodingBindingElement());

        var transportElement = new HttpsTransportBindingElement();

        customBinding.Elements.Add(transportElement);

但是,我不斷收到一條消息,指出:

The message could not be processed. This is most likely because the action is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings The message could not be processed. This is most likely because the action is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings

我可以肯定它與我的自定義綁定有關,但是我很難確定要把哪些屬性設置為什么。 感謝任何指導!!!

我認為客戶端時間和服務器時間不匹配,至少錯誤看起來像這樣...

您可以檢查一下計時器嗎?

如果我是對的,請參見以下內容: 如何:設置最大時鍾偏斜

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM