怎么动态改变webservice的地址?

解决方案 »

  1.   

    public class MyService :
    System.Web.Services.Protocols.SoapHttpClientProtoc ol {/// <res/>
    public MyService() {
    this.Url = "http://sha-schang-01/myservice/myservice.asmx";
    }
      

  2.   

    添加“web引用”后在web.congfig中自动添加web service的url地址,直接修改一下web.config中的地址即可。
      

  3.   

    做法需要2步:
    1,添加引用,在引用的属性里设置url为动态引用,此时会自动在 Web.config里<appSettings><add key="MyWebApp.localhost.Service1" 
    value=http://localhost/MyWebService/Service1.asmx/></appSettings>
    发布的时候只需要修改这个即可具体参考
    http://www.microsoft.com/china/MSDN/library/archives/library/dv_vstechart/html/vbtchredirectingapplicationtotargetdifferentXMLWebServiceduringinstallation.asp在安装期间将应用程序重定向到不同的 XML Web services
      

  4.   

    考虑下:在项目中加入一个类,在类中来得到web service的地址。需要引用web service的地方,先从类中读取地址。客户端web service地址可以考虑在注册表中来保存。
      

  5.   

    关注,最近才开始研究web service