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服务地址?