私が取り組んでいる古いWCFサービス/クライアントが得られました。新しい(静的な)ロギングシステムを追加しました。実際には現在、いくつかの負荷テストを行っています。WCF/wsHttpBinding/Message Security - BadTokenRequest
「リモートエンドポイントとのセキュリティネゴシエーションが失敗したため、セキュリティで保護されたチャネルを開くことができません」という疑わしい散発的な問題が発生しています。 BadContextTokenのSenderとサブコードのフォールト名でCommunicationExceptionを取得したことに気付きました。
奇妙なことですが、私は2〜4の正しい応答を得て、次にこれらの例外が慌てて、再び良い応答を得るようになります。
これは、WCFへの私の最初の本当の進出で、これまでのところ、それを愛していない:)
サービスのweb.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="MyNamespace.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyNamespace.IMyService" bindingConfiguration="wsMessage">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceCredentials>
<serviceCertificate findValue="MyValue" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNamespace.UserNamePassValidator, MyNamespace" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
とクライアント側で、クライアントがそのようなとしてインスタンス化されています。
var binding = new WSHttpBinding();
binding.Name = "WSHttpBinding_IMyService";
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
var client = new MyService(binding, "http://myserver:8080/myapp/service.svc");
var endpointIdentity = new DnsEndpointIdentity("MyValue"); // Match the certificate name used by the server
client.Endpoint.Address = new EndpointAddress(new Uri("http://myserver:8080/myapp/service.svc"), endpointIdentity, client.Endpoint.Address.Headers);
var creds = client.ClientCredentials;
creds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
creds.UserName.UserName = "myuser";
creds.UserName.Password = "mypassword";
string retVal = client.SendRequest(); // SendRequest == one of the methods on my IMyService, returns a string. This is also where I sporadically see my error when load testing.
私はこのWCF設定で私を助けてくれることを嬉しく思います!
何らかの理由でこれが役に立たない場合は、さらに詳しい情報が必要なのかどうか迷ってください。 –