ex-16-03

来自「Programming Csharp Source Code(代码) Prog」· 代码 · 共 51 行

TXT
51
字号
// Example 16-03: Sample client code to access the calculator web service

using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.Web.Services;

namespace WSCalc
{
   [System.Web.Services.WebServiceBindingAttribute(
       Name="Service1Soap", 
       Namespace="http://www.libertyAssociates.com/webServices/")]
   public class Service1 : 
      System.Web.Services.Protocols.SoapHttpClientProtocol 
   {
    
      public Service1() 
      {
         this.Url = 
              "http://localhost/webforms/wscalc/service1.asmx";
      }
    
      [System.Web.Services.Protocols.SoapDocumentMethodAttribute(
          "http://www.libertyAssociates.com/webServices/Add", 
          RequestNamespace=
            "http://www.libertyAssociates.com/webServices/", 
          ResponseNamespace=
             "http://www.libertyAssociates.com/webServices/", 
          Use=System.Web.Services.Description.SoapBindingUse.Literal, 
          ParameterStyle=
             System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
      public System.Double Add(System.Double x, System.Double y) 
      {
         object[] results = this.Invoke("Add", new object[] {x,y});
         return ((System.Double)(results[0]));
      }
    
      public System.IAsyncResult 
         BeginAdd(System.Double x, System.Double y, 
         System.AsyncCallback callback, object asyncState) 
      {
         return this.BeginInvoke("Add", new object[] {x,
                    y}, callback, asyncState);
      }
    
      public System.Double EndAdd(System.IAsyncResult asyncResult) 
      {
         object[] results = this.EndInvoke(asyncResult);
         return ((System.Double)(results[0]));
      }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?