Results 1 to 4 of 4

Thread: Web Service as function return value [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Web Service as function return value [RESOLVED]

    I want to be able to switch between a local test Web Service and a server
    based live Web Service.
    When testing numerous web forms I need to switch their Web Service reference between a local development service and the live one.
    At the moment this involves replacing the declaration 'TestWebService' with 'LiveWebService' in each form.
    What I would like to do is have a utilities class that has a static function
    that returns a reference to the appropriate web service depending upon a key
    in web.config.
    I would be able to do this if I knew how to declare the return value of the
    function:

    Code:
    internal static ???????? GetWebService()
    {
       string lstrWebService = 
           ConfigurationSettings.AppSetting["WebService"].ToString();
       if(lstrWebService == "Test")
       {
           return ????????;
       }
       else
       {
           return ????????;
       }
    }
    Anyone know what the ?????????s should be or if what I want is not possible.
    Last edited by GlenW; Jul 22nd, 2005 at 05:03 AM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Web Service as function return value

    What do you mean by returning a "a reference to the appropriate web service"? Can you show me an example?

  3. #3

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Web Service as function return value

    Quote Originally Posted by mendhak
    What do you mean by returning a "a reference to the appropriate web service"? Can you show me an example?
    I've got 2 Web Services referenced and I wanted to switch between them, but I now realise that this is totally the wrong way to do it!!!
    I'm going to have only one service referenced and change its URL when necessary. All I need to do is ensure that the services maintain the same contracts.
    A real blonde moment, or moments 'cos I've been doing it wrong for ages.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Web Service as function return value [RESOLVED]

    I was thinking along the same lines but your initial post confused me (with the Return values). The only thing that did require changing, as you've seen, was the .URL property...

Posting Permissions

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



Click Here to Expand Forum to Full Width