c# - How to change Location(Url) of a Web Service and Update Web Reference programmatically? -


i have web service:

http://127.0.0.1/something/somews.asmx 

i adding web reference app wont localhost... might change http://www.something.com/something/somews.asmx.

how change url programmatically of web reference? simple as:

using (var service = new myapi.myapi()) {     //txturl site     service.url = "http://" + txturl + "something/somews.asmx"; } 

also, once change it, how update programmatically? (equivalent right-clicking , selecting "update web reference")

side-note: trying accomplish dropdowns of available methods based on asmx webservice available on server (service.url)

as john saunders commented way trying take talk 2 versions of service not technically possible. trying mix compile/design time action ("update web reference") runtime one.

easy approach @ problem talking 2 different data sources providing similar data. researched approach plenty of samples - data repository 1 of search terms.

implementation:

  • one web reference per version of service
  • an interface exposes data need (the 1 can obtain web service)
  • one implementation of interface per web reference
  • have collection of interface implementations (i.e. dictionary map friendly name interface implementation) allows pick data source.

code:

interface imydata  {       string getlastname(); }  class mydatafromoldwebservice {     myapi.myapiv1 service;     mydatafromoldwebservice(myapi.myapiv1 service)     {       this.service = service;     }     public string getlastname()... }  dictionary<string, imydata> services = new dictionary<string, imydata>()   {       { "old service", new mydatafromoldwebservice(new myapi.myapiv1(url))}   }; 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -