0

C# を使用して、SOAP 経由で XML データを送信しています。#PasswordDigestこのサービスには、とによる HttpDigest 認証が必要です#Base64Binary Nonce。私たちのbindingコード:

protected BasicHttpBinding binding = new BasicHttpBinding()
{
            Name = "ShipmentServiceSoapBinding",
            CloseTimeout = new TimeSpan(0, 01, 0),
            OpenTimeout = new TimeSpan(0, 01, 0),
            ReceiveTimeout = new TimeSpan(0, 10, 0),
            SendTimeout = new TimeSpan(0, 5, 0),
            AllowCookies = false,
            BypassProxyOnLocal = false, 
            HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
            MaxBufferPoolSize = 5242880,
            MaxReceivedMessageSize = 655360,
            MessageEncoding = WSMessageEncoding.Text ,
            TextEncoding =  new UTF8Encoding(),
            UseDefaultWebProxy = true,
            ReaderQuotas = new XmlDictionaryReaderQuotas() { MaxDepth = 32, MaxStringContentLength = 81920, MaxArrayLength = 1638400, MaxBytesPerRead = 409600, MaxNameTableCharCount = 163840 },
            Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.TransportWithMessageCredential, 
                                                 //Message = new BasicHttpMessageSecurity() { AlgorithmSuite = SecurityAlgorithmSuite.Default, ClientCredentialType = BasicHttpMessageCredentialType.UserName}, 
                                                 Transport = new HttpTransportSecurity(){ ClientCredentialType = HttpClientCredentialType.Digest}},

};

選択している BasicHttpSecurityMode のタイプに基づいて、3 つの異なる問題が発生しています。

  1. トランスポート - XML にはセキュリティ情報が含まれていません
  2. TransportCredentialOnly - エンドポイントを https:// にすることはできないというエラーが表示されます。
  3. TransportWithMessagecredential - これはダイジェストを使用していません

ServiceReference で ClientCredentials クラスを使用できるようになったので、HttpDigest を使用してみました。

typeClient.ClientCredentials.HttpDigest.ClientCredential.UserName = "username";
typeClient.ClientCredentials.HttpDigest.ClientCredential.Password = "password";

他の StackOverflow の質問を読みましたが、ダイジェストには SoapHeader と AuthHeader を使用する必要がありますが、それを API にあるものと一致させる方法はありません。それを行う他の方法はありますか?それとも、API が C# 用に正しく記述されていないのでしょうか?

4