本文转自:http://blog.csdn.net/muyangjun/article/details/7930871

1、添加服务引用

2、在弹出的添加服务引用对话框地址栏中输入WebService地址,

   如:http://localhost:6521/WebSite1/Service.asmx?WSDL

3、输入命名空间名称或保持默认

4、定义SoapClient变量

          WebService.ServiceSoapClient SoapClient = new WindowsFormsApplication1.WebService.ServiceSoapClient();

5、将新的重新配置WebService的URL

            SoapClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:6521/WebSite1/Service.asmx?WSDL");

6、打开服务

            SoapClient.Open();

7、调用服务中已经存在的功能方法,如:调用Web服务中HelloWorld()

            SoapClient.HelloWorld();

8、调用完成后,关闭服务

            SoapClient.Close();

注意事项:

新地址的服务所提供的方法及其参数必须与引用的一致。

 

 

相关文章:

  • 2021-06-21
  • 2021-05-10
  • 2022-12-23
  • 2021-12-01
  • 2021-06-20
  • 2022-12-23
猜你喜欢
  • 2021-10-26
  • 2022-01-25
  • 2021-05-18
  • 2022-02-27
相关资源
相似解决方案