2011-09-13 11 views
1

C#では、HTTPSアドレスにあるWebサービスにアクセスしようとしています。私のコードは、DLLを使用してメインアプリケーションで参照されるクラスライブラリで定義されています。したがって、App.configファイルでWebサービスを設定する標準的な方法はここでは不可能です。HTTPSを使用してWebサービスにアクセスするとArgumentExceptionが発生する

var remoteAddress = new System.ServiceModel.EndpointAddress(
    "https://myUrl.com/Service.svc"); 
MyServiceClient myClient = new MyServiceClient(
    new System.ServiceModel.WSHttpBinding(), 
    remoteAddress); 
myClient.ClientCredentials.ClientCertificate.SetCertificate(
    StoreLocation.CurrentUser, 
    StoreName.My, 
    X509FindType.FindByThumbprint, 
    "91 47 0b e8 80 bf ee 68 32 93 f0 d4 ee e6 14 8c e5 0c fa 3e" 
    ); 
myClient.Endpoint.Binding.SendTimeout = new TimeSpan(0, 0, 0, 10); 
var myResult = myClient.MyMethod("foo bar"); 

しかし、私はWSHttpBindingを使用する場合でも、私はメッセージとArgumentExceptionが出ます:: 私のコードは次のように本質的に等しい

提供URIスキーム「HTTPS」は無効です。期待される 'http'。
パラメータ名:via

誰でも問題の原因を特定できますか?

+0

可能な重複が無効です。期待される 'http'。パラメータ名:via](http://stackoverflow.com/questions/2435823/the-provided-uri-scheme-https-is-invalid-expected-http-parameter-name-via) – vcsjones

答えて

0

SSL/TLS(https)を使用しているので、この情報を使用してWSHttpBindingインスタンスを作成することは理にかなっています。例えば。

new System.ServiceModel.WSHttpBinding() 

に新しいSystem.ServiceModel.WSHttpBinding(SecurityMode.xxx)を変更XXXhttp://msdn.microsoft.com/en-us/library/ms575161.aspxで定義され

[設けURIスキーム 'HTTPS' の

関連する問題