2016-10-26 7 views
1

私はcustom bindingの下に作成しています。getting end point address from configを送信してから、WCFサービスに要求を送信しようとしています。WCFサービスに接続する際の問題

BasicHttpBinding binding = new BasicHttpBinding(); 
binding.MaxReceivedMessageSize = int.MaxValue; 
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 

var endpointAddress = ""; 

ClientSection clientSection = (ClientSection)ConfigurationManager.GetSection("system.serviceModel/client"); 

for (int i = 0; i < clientSection.Endpoints.Count; i++) 
{ 
    if (clientSection.Endpoints[i].Name == "HTTPS_Port") 
    endpointAddress = clientSection.Endpoints[i].Address.AbsoluteUri; 
} 

EndpointAddress address = new EndpointAddress(endpointAddress); 
MyWCFService svc = new MyWCFService(binding, address); 

私はエラー

次提供URIスキーム 'HTTPS' は無効になってしまいます。 。。

答えて

3

あなたが輸送するセキュリティモードを使用していない}」を経由してあなたが

binding.Security.Mode = BasicHttpSecurityMode.Transport; 



According to definition => 



//Security is provided using HTTPS. The service must be configured with SSL 
    //  certificates. The SOAP message is protected as a whole using HTTPS. The service 
    //  is authenticated by the client using the service’s SSL certificate. The client 
    //  authentication is controlled through the System.ServiceModel.HttpTransportSecurity.ClientCredentialType. 

いけない

binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 

使用追加する必要があります。 は、 'HTTP' \ rを\名前nParameter期待このセキュリティモードは、httpベースのクライアントでのみ使用できます。

マイクロソフトによると このモードメッセージの完全性と機密性を提供しません。それは提供します

//  only HTTP-based client authentication. Use this mode with caution. It should 
//  be used in environments where the transfer security is being provided by 
//  other means (such as IPSec) and only client authentication is provided by 
//  the Windows Communication Foundation (WCF) infrastructure. 

注:このサービスをホストするにはSSL証明書が必要です。これはIISにインストールしてください。

+0

クライアントが共有するSOAPサービスに接続しています。私が 'Https'で 'Transport'を使用すると、バインディング(設定ファイル)に証明書が必要ですか?または、このサービスをホストしていたIISのクライアントでこの証明書をインストールする必要がありますか? – simbada

+0

証明書はwcfにのみ固有のものではありません。ホストされたIISマシンにインストールする必要があります。@ simbada – Rajput

関連する問題