Development Platform:. NET 2.0
Development tools: Visual Web Developer 2005 express edition beta Visual C #2005 express edition Beta
Service. asmx
<% @ WebService Language = "C #" codebehind = "~ /Code/service. cs "class =" myservicecs "%>
Service. CS
Using system;
Using system. Web;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. diagnostics;
Using system. Web. Services;
Using system. Web. Services. Protocols;
[Webservicebinding (conformanceclaims = wsiclaims. BP10, emitconformanceclaims = true)]
Public class myservicecs: system. Web. Services. WebService
{
Public myservicecs ()
{
}
[Webmethod]
Public int addnumbers (INT num1, int num2)
{
Return (num1 + num2 );
}
[Webmethod]
Public int subnumbers (INT num1, int num2)
{
Return (num1-num2 );
}
[Webmethod]
Public int mulnumbers (INT num1, int num2)
{
Return (num1 * num2 );
}
[Webmethod]
Public int divnumbers (INT num1, int num2)
{
Return (num1/num2 );
}
}
Form1.cs
# Region using directives
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Windows. forms;
# Endregion
Namespace arithcalculatorwebserviceclient
{
Partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}
Private myservicecs csservice = new myservicecs ();
Private void lblresult_click (Object sender, eventargs E)
{
Int result = csservice. addnumbers (int32.parse (txtnum1.text), int32.parse (txtnum2.text ));
Lblresult. Text = result. tostring ();
}
Private void btnsub_click (Object sender, eventargs E)
{
Int result = csservice. subnumbers (int32.parse (txtnum1.text), int32.parse (txtnum2.text ));
Lblresult. Text = result. tostring ();
}
Private void btnmul_click (Object sender, eventargs E)
{
Int result = csservice. mulnumbers (int32.parse (txtnum1.text), int32.parse (txtnum2.text ));
Lblresult. Text = result. tostring ();
}
Private void btndiv_click (Object sender, eventargs E)
{
Int result = csservice. divnumbers (int32.parse (txtnum1.text), int32.parse (txtnum2.text ));
Lblresult. Text = result. tostring ();
}
Private void form1_load (Object sender, eventargs E)
{
}
}
}