6

WCF クライアントからサード パーティの WSE 3.0 Web サービスに接続できません。この KB 記事に示されているように、カスタム バインディング クラスを実装しました。

http://msdn.microsoft.com/en-us/library/ms734745.aspx

この問題は、Web サービスで使用されるセキュリティ アサーション (UsernameOverTransport) に関係しているようです。

メソッドを呼び出そうとすると、次の例外が発生します。

System.InvalidOperationException: 'MyWebServiceSoap'.'[namespace]' コントラクトの 'WseHttpBinding'.'[namespace]' バインディングは、トランスポート レベルの整合性と機密性を必要とする認証モードで構成されています。ただし、トランスポートは完全性と機密性を提供できません。

ユーザー名、パスワード、および CN 番号が必要です。ベンダーから提供されたサンプル コードでは、これらの資格情報が Microsoft.Web.Services3.Security.Tokens.UsernameToken にバンドルされています。ベンダーから提供された例を次に示します。

MyWebServiceWse proxy = new MyWebServiceWse();

UsernameToken token = new UsernameToken("Username", "password", PasswordOption.SendPlainText);

token.Id = "<supplied CN Number>";

proxy.SetClientCredential(token);

proxy.SetPolicy(new Policy(new UsernameOverTransportAssertion(), new RequireActionHeaderAssertion()));

MyObject mo = proxy.MyMethod();

これは、WSE 3.0 がインストールされた 2.0 アプリから正常に動作します。これは、私の WCF クライアントからのコードのスニペットです。

EndpointAddress address = new EndpointAddress(new Uri("<web service uri here>"));

WseHttpBinding binding = new WseHttpBinding(); // This is the custom binding I created per the MS KB article

binding.SecurityAssertion = WseSecurityAssertion.UsernameOverTransport;
binding.EstablishSecurityContext = false;

// Not sure about the value of either of these next two
binding.RequireDerivedKeys = true;
binding.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;

MembershipServiceSoapClient proxy = new MembershipServiceSoapClient(binding, address);

// This is where I believe the problem lies – I can’t seem to properly setup the security credentials the web service is expecting 

proxy.ClientCredentials.UserName.UserName = "username";
proxy.ClientCredentials.UserName.Password = "pwd";
// How do I supply the CN number?                      

MyObject mo = proxy.MyMethod(); // this throws the exception

この質問に対する答えを探して、Web を精査しました。いくつかの情報源 (MS KB 記事など) は私を近づけますが、私はこぶを乗り越えることができないようです. 誰かが私を助けることができますか?

4

2 に答える 2

10

次のバインディング構成を使用して、同様のケースで成功しました。

<bindings>
   <customBinding>
      <binding name="FNCEWS40MTOMBinding">
         <security enableUnsecuredResponse="true" authenticationMode="UserNameOverTransport"
                   allowInsecureTransport="true" messageProtectionOrder="SignBeforeEncrypt">
            <secureConversationBootstrap />
         </security>
         <mtomMessageEncoding messageVersion="Soap12WSAddressingAugust2004"
                              maxBufferSize="2147483647" />
         <httpTransport maxReceivedMessageSize="2147483647" />
     </binding>
  </customBinding>
</bindings>

それがあなたにとってもうまくいくことを願っています。

于 2011-10-11T06:51:17.103 に答える
1

エラー メッセージは、Transport Level Security を参照しています。これは通常、https を意味します。

構成ファイルを表示していません。しかし、セキュリティをトランスポートに構成し (または、別の選択の結果として必要になる)、https ではなく http のアドレスを使用したと推測しています。

于 2009-08-10T12:29:39.570 に答える