C#调用webservice 不用默认配置文件 直接在构造函数配置地址

 

ClientBase(Binding binding, EndpointAddress remoteAddress) 这个重载更好用,都不用填名称

 

例如 获取随机汉字

http://www.webxml.com.cn/WebServices/RandomFontsWebService.asmx

            ServiceReference1.RandomFontsWebServiceSoap d =
                new ServiceReference1.RandomFontsWebServiceSoapClient(
                    new BasicHttpBinding(),
                    new EndpointAddress("http://www.webxml.com.cn/WebServices/RandomFontsWebService.asmx")
            );

            string[] arr = d.getChineseFonts(5);

  

 

文章来源  https://www.cnblogs.com/longling2344/p/6255846.html 

posted on 2020-12-16 15:05  苏上话  阅读(339)  评论(0编辑  收藏  举报