This is a discussion on Webservice and its uses within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi, Could anyone tell me,how to create webservice and how to use it?..Plz explain it with simple program.....
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi Poornima, To create a new webservice: File --- > New --- > Website ---- > ASP.NET Webservice. Create a function in the webservice . Ex : [webmethod] public int Sum(int a, int b) { return a+b; }
__________________ S.Balasubramanian Nothing is impossible |
| |||
| Advantages of Web Service : Web Service messages are formatted as XML, a standard way for communication between two incompatible system. And this message is sent via HTTP, so that they can reach to any machine on the internet without being blocked by firewall.
__________________ S.Balasubramanian Nothing is impossible |
| |||
| Hi kirubananth, U can call webservice from aspx page code-behind Suppose in Webservice named WebServiceDemo.cs, You are having the methods like, [webmethod] public int add(int a,int b) { int c; c=a+b; return c; } [webmethod] public string myWorld() { return "Hai DotNet Guys"; } After u including these methods, RightClick over the solution->Add WebReference->Start Browsing for Web Services->Web services in this solution-> Services Project URL WebServiceDemo D:\...\WebServiceDemo\ WebServiceDemo.asmx The following operations are supported. For a formal definition, please review the Service Description. *add *myWorld Click over add,then it will ask the parameters to u, Test To test the operation using the HTTP POST protocol, click the 'Invoke' button. Parameter Value a: 5 b: 6 Invoke->Button After u click invoke,U will get the result like this <?xml version="1.0" encoding="utf-8" ?> <int xmlns="http://tempuri.org/">11</int> From the above one '11' is the answer u get. To call this in Code-Behind Default.aspx.cs protected void addButton_Click(object sender,EventArgs e) { WebServiceDemo webServiceDemo=new WebServiceDemo(); demoTextBox1.Text=webServiceDemo.add(5,6).ToString (); } Thats all, now u will get the resultant value in the textbox in ur aspx page by clicking Add button in ur aspx page. |
| |||
| Thank you poornima, I really learned more from your post. I have a doubt. What is the difference between the ordinary mehod and the method from the webservice? |
| |||
| Hi kirubananth, If u r using ordinary method either u can use that method in a web Page or within ur project.But if u use web Method u can use that web method any where in ur project and u can use that web method in various projects if it is necessary..This s d differece.R u clear? |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ASP.net 2.0 Webservice and WCF | kingmaker | ASP and ASP.NET Programming | 1 | 10-11-2007 04:15 AM |
| HTTPWebRequest in webservice | S.Vinothkumar | ASP and ASP.NET Programming | 4 | 09-26-2007 12:40 AM |
| Error in webservice | Sathish Kumar | C# Programming | 7 | 09-20-2007 04:55 AM |
| Webservice – Xml & Soap | Karpagarajan | XML and SOAP | 1 | 08-31-2007 11:45 PM |
| note on webservice | nssukumar | Java Programming | 1 | 03-12-2007 05:05 AM |