georgepatotk Posted February 18, 2006 Posted February 18, 2006 I don't know whether this is called dynamic web reference. My problem is this, I have a web service in assume http://abc/myservice.asmx, so, i link my program to this address to call the reference. But, the address will be change from time to time and I don't want to recompile my program just because of the changes of the address. What i wanna do is write a simple module to store the latest address on the run time, and the reference will refer to theaddress. Please helps. Thanks... Quote George C.K. Low
Cags Posted February 18, 2006 Posted February 18, 2006 You could store the address in either a textfile or the registry, then simply look up the address when you boot up the program. Quote Anybody looking for a graduate programmer (Midlands, England)?
georgepatotk Posted February 18, 2006 Author Posted February 18, 2006 U are right, this is the way. But, how to edit the referece? I should be doing some thing like Webreference.URL = "http://abc/Webservice.asmx" But, where to do this? Like in database, we have conn.ConnectionString = "bla bla bla" Quote George C.K. Low
Cags Posted February 18, 2006 Posted February 18, 2006 Well I'm not going to pretend to know anything much about web development, so if I speak nonesense then just ignore me. When you say WebReference are you talking about a System.Web.Services.Description.WebReference object or something else? Quote Anybody looking for a graduate programmer (Midlands, England)?
Administrators PlausiblyDamp Posted February 18, 2006 Administrators Posted February 18, 2006 If you added the web reference via VS then you can select the webreference through the solution explorer and in the property grid change it from static to dynamic. This will move the URL to the appropriate config file (web.config or app.config) for you. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
georgepatotk Posted February 19, 2006 Author Posted February 19, 2006 Dear PlausiblyDamp, Yes, I had change the URL from static to Dynamic but it is not working still. Let me tell u my case, I did like this, ws.URL = "http://192.168.0.155/Webservice/Ordering.asmx" but, it doesn't works. And for ur information, this is not a web application so, it doesn't have web config and app config. What I do is like what Cags suggested, store the value into a file and read from the file. And lastly, my application is a pocket pc application. Please guide me. Thanks Quote George C.K. Low
georgepatotk Posted February 23, 2006 Author Posted February 23, 2006 anyone could give me a helping hand, please... Quote George C.K. Low
Administrators PlausiblyDamp Posted February 23, 2006 Administrators Posted February 23, 2006 If it is a windows application or a console application it will have an app.config file. The single line of code you posted should work - however without seeing what else you are doing or more details about how it is failing to work it is quite difficult to help. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
georgepatotk Posted February 27, 2006 Author Posted February 27, 2006 Dear PlausiblyDamp, I problem here is after i change the property to dynamic, the app.config file is not automatically generated, and if i store the value into a text file and assign using ws.URL = "http://192.168.0.155/Webservice/Ordering.asmx", it is not working as well. Please guide me... Quote George C.K. Low
Mister E Posted March 24, 2006 Posted March 24, 2006 Use the WSDL tool to generate a proxy class. This essentially does the exact same thing as when you add a Web Reference in Visual Studio -- except that you will now have the underlying .cs file. The command line call to do this might look something like this:wsdl /out:MyWebServiceProxy.cs [url]http://localhost/blah/service.asmx[/url]This will build the "MyWebServiceProxy.cs" proxy file. Include this in your project and then open up the file. You will notice that the constructor looks like this:public Service() { this.Url = "http://localhost/blah/service.asmx"; }You will also notice that this is the only location where the Url is set. So I usually just modify the constructor to look something like this:public Service(string server) { this.Url = string.Format("http://{0}/blah/service.asmx", server); }You can also then wrap the class in your own namespace if you want. From here you can now create an instance of the proxy class with something like the following: MyNamespace.ServiceX service = new MyNamespace.ServiceX("localhost"); service.HelloWorld();You can then set the server reference as needed by creating new instances of the proxy class. All should work well provided that all servers share the same version of the Web Service. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.