WCF で WS-Security 対応サービスを利用しようとしています。認証は UsernameToken を使用して機能します。私は WCF Web サービス クライアントについてあまり詳しくありませんが、以下の構成は通常の HTTP 通信で機能すると思います。私は(ほとんど)このガイドを使用して構成しました。主な違いは、コマンド プロンプトの代わりに VS2010 の「サービス参照の追加」UI を使用したことです。
私の問題は、HTTPS 経由でこれを行う必要があることです。<security mode="Message">
app.config で使用すると、soap エンベロープに必要な WS-Security ヘッダーが含まれていると思います。ロギングを機能させることができないため、はっきりとは言えません。ただし、次のエラーが表示されますThe provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via
。
以下は、私の app.config ファイルの内容とクライアント コードのサンプルです。
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Omitted" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Message">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" negotiateServiceCredential="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://omitted.com/service" binding="wsHttpBinding" bindingConfiguration="Omitted" contract="Omitted.Omitted" name="Omitted" />
</client>
</system.serviceModel>
var service = new OmittedClient();
service.ClientCredentials.UserName.UserName = "username";
service.ClientCredentials.UserName.Password = "password";
var response = service.DoSomething(new DoSomethingRequest());