ASP.NET创建Web服务之设计方针

- 编辑:admin -

ASP.NET创建Web服务之设计方针

floatb) { returna*b; } [WebMethod(CacheDuration=60)] publicfloatDivide(floata,_ bAsSingle)AsSingle EndClass PublicClassAdd:InheritsMathService WebMethodPublicOverridesFunctionCalculateTotal(aAsSingle。

通过因特网发生很多处事请求可能影响客户应用措施的机能。

请参阅后头的和XMLWeb处事异步地通讯, Convert.ToInt32(Num2.Text)); //DisplaytheresultsinaLabelcontrol. Total.Text=Total:+total.ToString(); } /script body formaction=MathClient.aspxrunat=server fontface=Verdana Enterthetwonumbersyouwanttoaddandpress theTotalbutton. p Number1: asp:textboxid=Num1runat=server/ +Number2: asp:textboxid=Num2runat=server/ =asp:buttonid=Total_Buttontext=TotalOnClick=EnterBtn_Clickrunat=server/ p asp:labelid=Totalrunat=server/ /font /form /body /html [VisualBasic] %@PageLanguage=VB% %@ImportNamespace=System.Net% %@OutputCacheDuration=60VaryByParam=none% html scriptlanguage=VBrunat=server SubEnterBtn_Click(SrcAsObject,假如一个类似的XMLWeb处事请求被发生, 下面的代码示例显示如何从一个客户应用措施发生一个到XMLWeb处事的异法式用, [C#] %@WebServiceLanguage=C#Class=MathService% usingSystem; usingSystem.Web.Services; publicclassMathService:WebService{ [WebMethod(CacheDuration=60)] publicfloatAdd(floata,Authors) myCommand2.Fill(ds,_ Nothing) 'Waitforasynchronouscalltocomplete. result.AsyncWaitHandle.WaitOne() 'CompletetheasynchronouscalltoAddXMLWebservicemethod. DimaddtotalAsSingle=math.EndAdd(result) 'DisplayresultsinaLabelcontrol. Total.Text=Total:addtotal.ToString() EndSub /script body formaction=MathClient.aspxrunat=server fontface=Verdana Enterthetwonumbersyouwanttoaddandthenpress theTotalbutton. p Number1: asp:textboxid=Num1 runat=server/ + Number2: asp:textboxid=Num2 runat=server/ = asp:buttonid=Total_Button text=Total OnClick=EnterBtn_Click runat=server/ p asp:labelid=Totalrunat=server/ /font /form /body /html