0
私のWCFサービスはどのサーバーでも動作します。私のクライアントはコンソールアプリケーションです。コマンドラインパラメータでは、私のWCFサービスのアドレスを設定します。私が持っている設定クライアントで 電流:spring.netを使用している場合、クライアントのコマンドラインからWCFサービスのアドレスを設定する方法
...
<spring>
<context>
<resource uri="assembly://MyAssembly.Console/MyAssembly.Console/ServerWeb.xml"/>
</context>
</spring>
...
<system.serviceModel>
<client>
<endpoint behaviorConfiguration="Default" name="serverWebDataServiceEndpoint" address="http://localhost/mydata/DataService.svc"
binding="basicHttpBinding" bindingConfiguration="basicHttpBinding1" contract="MyData.Contracts.IDataService"/>
</client>
...
ファイルServerWeb.xmlがある:アプリケーションで
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:wcf="http://www.springframework.net/wcf">
<wcf:channelFactory id="serverWebDataService"
channelType="VimpelCom.Fmrad.Theseus.WcfDataLayer.CommonTypes.Contracts.IDataService, VimpelCom.Fmrad.Theseus.WcfDataLayer.CommonTypes"
endpointConfigurationName="serverWebDataServiceEndpoint" />
</objects>
、私はコールサービスのメソッドのために、次のコードを使用します。
IApplicationContext _ctx = ContextRegistry.GetContext();
IDataService _dataService = _ctx["serverWebDataService"] as IDataService;
var rule = _dataService.GetRuleById(ruleId);
どのようにコマンドラインからWCFサービスの別のアドレスを使用できますか?あなたはコマンドラインからプロパティ値を取得するためにIVariableSource抽象化を使用することができます
<wcf:channelFactory id="serverWebDataService"
channelType="VimpelCom.Fmrad.Theseus.WcfDataLayer.CommonTypes.Contracts.IDataService, VimpelCom.Fmrad.Theseus.WcfDataLayer.CommonTypes"
endpointConfigurationName="serverWebDataServiceEndpoint">
<!-- You can use classic DI to configure the ChannelFactory<T> instance -->
<wcf:property name="Endpoint.Address">
<object type="System.ServiceModel.EndpointAddress, System.ServiceModel">
<constructor-arg name="uri" value"${serviceUrl}"/>
</object>
</wcf:property>
</wcf:channelFactory>
: