我编写好一个Webservice 后 
Winfrom 引用这个WebService 即可使用其中的方法
如果WebService 的IP变了 就要重新 引用没什么办法能够直接改为WebService 的IP 实现动态引用谢谢

解决方案 »

  1.   

    添加Web引用. 引用名称改了. 比如MyService
     
    就像实例化普通类的对象一样 使用他.
      

  2.   

    cstester 正解
    鉴定完毕~
      

  3.   

    配置相关信息到XML,获取XML中值实现调用
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.Services.Protocols;
    using System.Configuration;namespace Service
    {
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Web.Services.WebServiceBindingAttribute(Name = "ServiceSoap", Namespace = "http://tempuri.org/")]
        internal class ServiceProxy : SoapHttpClientProtocol
        {
            public ServiceProxy()
            {
                //this.Url = ConfigurationManager.AppSettings["Url"];
            }        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Server1", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            public System.Data.DataSet Server1(string strObjType, string strObjValues)
            {
                object[] results = this.Invoke("Server1", new object[] {
                        strObjType,
                        strObjValues});
                return ((System.Data.DataSet)(results[0]));
            }        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Server2", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            public System.Data.DataSet Server2(string strObjType, string strObjValues)
            {
                object[] results = this.Invoke("Server2", new object[] {
                        strObjType,
                        strObjValues});
                return ((System.Data.DataSet)(results[0]));
            }
        }
    }
      

  5.   

    如果你使用反射来调用可以参考.
    http://blog.csdn.net/zgke/archive/2009/03/04/3955490.aspx
      

  6.   

    调用时候用以下语句
                using (ServiceProxy proxy = new ServiceProxy())
                {
                    proxy.Url = ConfigurationManager.AppSettings["Url"];
                    DataSet ds = proxy.Server1("USERS", cardID);
        }
      

  7.   

    看你用的2003还是2005或是2008了.
    2003下面动态引用很麻烦.要通过代码生成引用代码,并编译
    2005下面可直接能WEBSERVER的属性URL进行修改就行了如S_schoolManage.Url = "http://111,222,23,56/schoolmanage.asmx"
      

  8.   

    反射调用~~~
    在baidu里面搜搜,有很多~~~
      

  9.   

    可以不生成程序集,直接调用WebService吗?