how to refer Service URL from <applicationSettings> in web.config RRS feed

  • Question

  • HI,

    I have a class library project with WCF service references.

    When I do that I see below entries in app.config :

        <bindings />
        <client />
            <setting name="Test_Data_StudentWebService" serializeAs="String">

    I tried below:

    <system.serviceModel> <bindings> <basicHttpBinding> <!--Code omitted for clarity--> </basicHttpBinding> </bindings> <client> <endpoint address="HOW TO REFER SERVICE NAME FROM <APPLICATIONSETTINGS>"


    bindingConfiguration="testBinding" contract="StudentWebService"

    name="ServiceEndpoint" /> </client> </system.serviceModel>

    How can I refer to service URL and add binding information to this service ? 

    Any help is appreciated ?


    • Edited by Sanjay Sutar Thursday, November 21, 2013 4:16 PM
    Thursday, November 21, 2013 4:13 PM


  • Hi,

    You can get the service url by using the following:

    string uri = Test.Data.Properties.Settings.Test_Data_StudentWebService;

    Then you can call the service by using the ChannalFactoy like below:

           BasicHttpBinding myBinding = new BasicHttpBinding();
           string uri1 = Test.Data.Properties.Settings.Test_Data_StudentWebService;
            EndpointAddress myEndpoint = new EndpointAddress(uri1);
            ChannelFactory<IMath> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
            // Create a channel.
            IService1 wcfClient1 = myChannelFactory.CreateChannel();

    #How to use ChannalFactoy: .

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 22, 2013 6:59 AM