Programmatically add / remove web reference in C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TC

    Programmatically add / remove web reference in C#

    Hello All,

    I have winforms app that accesses a webservice and the WSDL is referenced
    dynamically.

    I was wondering 2 things:

    First, if one parses the .config file and changes the URL pointing to the
    WSDL, I take it that these changes would not take effect until the user
    closes and restarts the app, correct?

    The above said, is there a way to programmtically upload the newly parsed
    ..config file, or, better yet, is there a way to programmaticall y remove the
    old reference and add a new reference pointing to the new WSDL?

    Thanks & Regards,

    TC



  • Sami Vaaraniemi

    #2
    Re: Programmaticall y add / remove web reference in C#


    "TC" <getmyemails2@y ahoo.com> wrote in message
    news:%23Odbo92R FHA.1396@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > Hello All,
    >
    > I have winforms app that accesses a webservice and the WSDL is referenced
    > dynamically.
    >
    > I was wondering 2 things:
    >
    > First, if one parses the .config file and changes the URL pointing to the
    > WSDL, I take it that these changes would not take effect until the user
    > closes and restarts the app, correct?[/color]

    I take it you mean the Web Reference is dynamic, right? If so, then you are
    correct, changes to the config file will not take effect until the app is
    restarted. That's because the config file loader loads the .config file only
    at first time you ask for a setting. After that all requests come from an
    in-memory cache.
    [color=blue]
    >
    > The above said, is there a way to programmtically upload the newly parsed
    > .config file, or, better yet, is there a way to programmaticall y remove
    > the old reference and add a new reference pointing to the new WSDL?[/color]

    If you just want to change the url of the Web Service proxy, assign to the
    Url property of the proxy object. This works assuming the Web Service
    interface (i.e., the WSDL) is the same.

    Regards,
    Sami


    Comment

    • Keenan Newton

      #3
      Re: Programmaticall y add / remove web reference in C#

      Well I am assuming your trying to change the URL where your web service
      is found at runtime. This is very easy to do by changing the URL
      property on the generated web service proxy.

      However, if your intent is to generate a new web service proxy on the
      fly from a wsdl file. Then you would have to create your very own class
      generator to interupt the wsdl, and generate a class file, compile that
      file, and use refelction to call it up. To say the least not an easy
      task.

      Comment

      • TC

        #4
        Re: Programmaticall y add / remove web reference in C#

        Hey Guys,

        Yep. I now see the 'URL' property of the proxy object.

        Thanks a bunch! It's exactly what I was looking for.

        Regards,

        TC

        "Keenan Newton" <kameleon_dj@ya hoo.com> wrote in message
        news:1114265300 .547149.294150@ l41g2000cwc.goo glegroups.com.. .[color=blue]
        > Well I am assuming your trying to change the URL where your web service
        > is found at runtime. This is very easy to do by changing the URL
        > property on the generated web service proxy.
        >
        > However, if your intent is to generate a new web service proxy on the
        > fly from a wsdl file. Then you would have to create your very own class
        > generator to interupt the wsdl, and generate a class file, compile that
        > file, and use refelction to call it up. To say the least not an easy
        > task.
        >[/color]


        Comment

        Working...