Results 1 to 2 of 2

Thread: How change address of WCF service from client in runtime

  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Default How change address of WCF service from client in runtime

    Hello!

    My WCF service can work on any servers. My client - is console application. In command line parameters I want set address of my WCF service.
    Current in config client I have:
    Code:
    ...
    <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>
    ...
    File ServerWeb.xml is:

    Code:
    <?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>
    In application, I use next code, for call service's methods:

    Code:
    IApplicationContext _ctx = ContextRegistry.GetContext();
    IDataService _dataService = _ctx["serverWebDataService"] as IDataService;
    
    var rule = _dataService.GetRuleById(ruleId);
    How I can use another address of WCF service from command line?

  2. #2
    Join Date
    Jun 2007
    Posts
    155

    Default

    I guess your proxy will be derived from ClientBase<T> which has Endpoint property. Use it to set address before call.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •