-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Varad_RS
Message 2 in Discussion

Hi Deepak,   You can get good article and information on WebServices at MSDN. Better 
utilize that.   To just start with a Webservice, here is some sample code for creating 
and deploying a simple webservice in C#.    
Creating A Webservice  
1.Create a folder named Webservice under wwwroot  
2. Create a File <%@ WebService Language="c#" Class="AddNumbers"%>  using System; 
using System.Web.Services; public class AddNumbers : WebService {  [WebMethod]  public 
int Add(int a, int b){   int sum;   sum = a + b;   return sum;  } } 3.Save this file 
as AddService.asmx [asmx-> file extension]  
4.Now the webservice is created and ready for the clients to use it.  
5. Now we can call this webservice using  
http://ip address/Webservice/Addservice.asmx/Add?a=10&b=5  
This will return the result in XML format  
Deploying the Webservice in the Client Machine  
1.At the command prompt:  
WSDL http://ip address ofthe site/WebService/MathService.asmx /n:NameSp 
/out:FileName.cs]
-This will create a file called FileNmame.cs .  
WSDL -> WebServices Description Language (This is an application available at 
C:\Program  
Files\Microsoft.NET\FrameworkSDK\Bin)  
NameSp -> Name of the NameSpace which will be used in client code for deploying the 
webservice.  
2.Compilation  
CSC /t:library /r:system.web.dll /r:system.xml.dll CreatedFile.cs  
This will create a dll with the name of the public class of the asmx file.( In our 
case, it is "AddNumbers.dll" )  
CSC is an application available at C:\WINNT\Microsoft.NET\Framework\v1.0.2914  
3.Put the dll file inside WWWRooT\BIN [Create a BIN Folder in WWWRoot]  
Making use of WebService in client asp/aspx page  
<%@ import Namespace = "NameSp" %> <script language = "c#" runat = "server"> public 
void Page_Load(object o, EventArgs e){  int x = 10;  int y = 5;  int sum;  
//Instantiating the public class of the webservice  AddNumbers AN = new AddNumbers();  
sum = AN.Add(x,y);  string str = sum.ToString();  response.writeline(str); } </script> 
Note  
It is advisable to  
1. Copy the .asmx file to the folder containing WSDL aplication (C:\Program 
Files\Microsoft.NET\FrameworkSDK\Bin) before creating cs file.  
2. Copy the created .cs file to the folder containing CSC application  
(C:\WINNT\Microsoft.NET\Framework\v1.0.2914) before compliling it. 
Hope this helps. 
Rgds, 
Varad. 
  
   

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to