Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

  • party42

    party42

    Participant

    1150 Points

    351 Posts

    Changing ServiceReference doesn't change endpoint

    May 23, 2008 03:42 AM | LINK

    Hiya guys,

    following this article by Pete Brown (here) he says:

    Note that the default endpoint has the address in the file. You can override this in code if you desire. However, since this is a configuration file, you'll probably want to change (and maintain) the endpoint address in the config here, prior to deploying your app to test/production.

    Now, especially the last sentence, it sounds great but it just doesn't work. Chaning the endpoint address in the ServiceReferences.ClientConfig file somehow doesn't change the endpoint. Here's the code I use to find that out:

    private static SoapClient InitService()
            {
                BasicHttpBinding binding = new BasicHttpBinding()
                {
                    MaxBufferSize = int.MaxValue,
                    MaxReceivedMessageSize = int.MaxValue
                };

                SoapClient p = new SoapClient();

                EndpointAddress address = new EndpointAddress(p.EndPointAddress);
                return new SoapClient(binding, address);
            }

    test 1: endpoint is set by default to say http://www.foo.com/foo.svc
    Output 1; p.EndPointAddress = http://www.foo.com/foo.svc

    test 2: changing endpoint in service reference to http://www.foo2.com/foo2.svc
    Output 1; p.EndPointAddress = http://www.foo.com/foo.svc

    Anyone know howto fix this? Obviously I can reset it in the above "Init()" method using hardcoded strings but hey... [:S]

    Cheers, Nathan 


    Regards,
    Nathan Brouwer

    http://www.nathanbrouwer.nl