Programmatically add / remove web reference in C#

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default 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 programmatically remove the
    old reference and add a new reference pointing to the new WSDL?

    Thanks & Regards,

    TC



    TC Guest

  2. Similar Questions and Discussions

    1. #25419 [NEW]: Call-time pass-by-reference has been deprecated but without it it's impossible to pass a object-reference via call_user_function
      From: roland at inkoeln dot com Operating system: Linux PHP version: 4.3.3 PHP Bug Type: Variables related Bug description: ...
    2. Returning a reference to an existing C++ object as a reference
      Hi All, Given: package x; sub new { return bless {}, $_; } #-- callback() is call by the C++ class (reader_as_cpp_object) #-- whenever...
    3. object reference-error with programmatically loading user control
      Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the...
    4. how to remove a programe from the add/remove list manually
      i am using winXP home, i just remove a programe from the start menu(start>>all programes>>name of the programe>>uninstall),but the programe name is...
    5. Cannot remove old server reference in Offline Files
      Ok, here's the issue: Using group policy to redirect users My Doc's to their user directory on the server. After rebuilding that server to...
  3. #2

    Default Re: Programmatically 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.

    Keenan Newton Guest

  4. #3

    Default Re: Programmatically 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@yahoo.com> wrote in message
    news:1114265300.547149.294150@l41g2000cwc.googlegr oups.com...
    > 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.
    >

    TC Guest

  5. #4

    Default Re: Programmatically add / remove web reference in C#

    your web service class must be like this:
    public class sample: System.Web.Services.Protocols.SoapHttpClientProtoc ol
    {
    [WebMethod]
    public string Hello()
    {
    return "Hi";
    }
    }

    and then add refrence in your project.when you want call method change url:
    sample s=new sample();
    s.Url = "http://host/sample.asmx";
    Response.Write(s.Hello());
    MjSh Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139