C# SOAP 调用WebService

  1. Math</CODE> XML Web services 生成的代理类。在代理类的 <CODE>Add</CODE> 方法中,<B>Invoke</B> 方法正在调用 <CODE>Add</CODE> XML Web services 方法。<P></P><CODE>   
  2. namespace MyMath {   
  3.     using System.Diagnostics;   
  4.     using System.Xml.Serialization;   
  5.     using System;   
  6.     using System.Web.Services.Protocols;   
  7.     using System.Web.Services;   
  8.        
  9.        
  10.     [System.Web.Services.WebServiceBindingAttribute(Name="MyMathSoap", Namespace="http://www.contoso.com/")]   
  11.     public class MyMath : System.Web.Services.Protocols.SoapHttpClientProtocol {   
  12.            
  13.         [System.Diagnostics.DebuggerStepThroughAttribute()]   
  14.         public MyMath() {   
  15.             this.Url = "http://www.contoso.com/math.asmx";   
  16.         }   
  17.            
  18.         [System.Diagnostics.DebuggerStepThroughAttribute()]   
  19.         [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.contoso.com/Add", RequestNamespace="http://www.contoso.com/", ResponseNamespace="http://www.contoso.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]   
  20.         public int Add(int num1, int num2) {   
  21.             object[] results = this.Invoke("Add"new object[] {num1,   
  22.                         num2});   
  23.             return ((int)(results[0]));   
  24.         }   
  25.            
  26.         [System.Diagnostics.DebuggerStepThroughAttribute()]   
  27.         public System.IAsyncResult BeginAdd(int num1, int num2, System.AsyncCallback callback, object asyncState) {   
  28.             return this.BeginInvoke("Add"new object[] {num1,   
  29.                         num2}, callback, asyncState);   
  30.         }   
  31.            
  32.         [System.Diagnostics.DebuggerStepThroughAttribute()]   
  33.         public int EndAdd(System.IAsyncResult asyncResult) {   
  34.             object[] results = this.EndInvoke(asyncResult);   
  35.             return ((int)(results[0]));   
  36.         }   
  37.     }   
  38. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值