2011-12-22 15 views
0

WebアプリケーションにWCF Servicereferenceを追加しました。次のエントリがweb.configに作成されました。Azure ServiceConfigからWCFサービスを呼び出す

<system.serviceModel> 
<bindings> 
    <wsHttpBinding> 
    <binding name="WSHttpBinding_INameVerification" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
     textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
     enabled="false" /> 
     <security mode="Transport"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="Windows" negotiateServiceCredential="true" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
    <endpoint address="https://int. NameVerification.com/Default/NameVerificationService.svc" 
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_INameVerification" 
    contract="NameVerificationService.INameVerification" 
    name="WSHttpBinding_INameVerification" /> 
</client> 

今私はAzureのクラウドプラットフォームに自分のアプリケーションをホストするために計画しています。私はいつでも すなわち。で私のエンドポイントを変更できるようにするクラウド上で自分のアプリケーションをホストすると 、

<endpoint address=”https://int. NameVerification.com/Default/NameVerificationService.svc” 
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_INameVerification" 
    contract="NameVerificationService.INameVerification" 
    name="WSHttpBinding_INameVerification" /> 

にはどうすればSericeConfigから私のWCFサービスにこの呼び出しを追加しますか?実際entriessがで何ですかServiceConfigを使用して、アプリケーションが自分のWCFエンドポイントアドレスをWeb.configからではなくService configから読み込むようにします。

答えて

2

はあなたの助けありがとうございました。

この問題の解決策が見つかりました。

  1. 関連のプログラムに結合し、serviceaddress、その後、Serviceconfig
  2. を 設定を追加ServiceConfigエントリは、私がServiceConfiguration内部の正確な設定項目を探していました
<Setting name="myServiceAddressUrl" 
    value="https://int. 
    NameVerification.com/Default/NameVerificationService.svc" /> 
WSHttpBinding binding = new WSHttpBinding(); 
    binding.Name = "WSHttpBinding_INameServiceVerification"; 
    binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; 
    binding.ReliableSession.Enabled = false; 
    binding.TransactionFlow = false; 
    binding.Security.Mode = SecurityMode.Transport; 
    binding.Security.Message.ClientCredentialType = 
     MessageCredentialType.Windows; 

    string myServiceAddressUrl = 
     RoleEnvironmentWrapper.GetConfigurationSettingValue(
      "AdderssServiceURL.svc"); 
    EndpointAddress myService = new EndpointAddress(myServiceAddressUrl); 

    NameVerificationClient verificationClient = 
     new NameVerificationClient(binding, myService); 
0

コンソールユーティリティで起動タスクを使用してRoleEnvironmentから設定を読み込み、手動で(またはServiceManagerを使用して) 。 別のオプションとして、明示的なサービス作成の前にService Factoryを使用してロール構成を読み取る方法があります。

おそらくそれはまたWebRoleのOnStartメソッドを使用することによって達成することができますが、私はこの時点で、web.configファイルを変更しても安全であるかどうかわからないんだけど

+0

を追加しました.cscfg。パッケージがAzureに入ったら、私はe ServiceConfiguration.cscfgを実行し、私のアドレスを変更する= "https:// staging。 NameVerification.com/Default/NameVerificationService.svc " – amazing

0

私が正しく理解していれば、あなただけの変化に探していますAzureで動作しているサービスを消費するアプリケーションを再デプロイせずに消費するサービスのエンドポイント?このサービスはあなたのソリューションの外部にあるように見えるので、実際のサービスのエンドポイントを変更するつもりはありませんか?

もしそうなら、アプリケーションをweb.configファイルで指定されたエンドポイントの設定に依存させずに、代わりにServiceConfigファイルのエンドポイント設定を測ることをお勧めしたいと思います。あなたのサードパーティのエンドポイントを呼び出すためにプロキシを構築するときに手動で解析します。こうすることで、web.configから何を得ているのかを完全に制御できるようになります(おそらくバインド設定はweb.configによって引き続き可能です)。そして、あなたはServiceConfigから何を得ていますか(エンドポイントUrLなど) ServiceConfigで後でエンドポイントを切り替えたり、アプリケーションの再デプロイメントを行わないで、アプリケーションを停止することができます。

ServiceConfigから読み込むためにAzure(実数またはエミュレータ)で実行している場合は、RoleEnvironmentをチェックする必要があります。

HTH

関連する問題