IT Community - Software Programming, Web Development and Technical Support

Webservice and its uses

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.....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-16-2008, 09:09 PM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Webservice and its uses

Hi,
Could anyone tell me,how to create webservice and how to use it?..Plz explain it with simple program..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-16-2008, 11:29 PM
Balasubramanian.S Balasubramanian.S is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 181
Balasubramanian.S is on a distinguished road
Default Re: Webservice and its uses

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-16-2008, 11:33 PM
Balasubramanian.S Balasubramanian.S is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 181
Balasubramanian.S is on a distinguished road
Default Re: Webservice and its uses

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-17-2008, 12:11 AM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Question Re: Webservice and its uses

Hi balu,

How can we call this web service function in another web page?
Please narrate it with an example.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-17-2008, 12:21 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Re: Webservice and its uses

Hi,
Thanks for ur post...
Shall v able to use xml file and do process and then return in the form of dataTable?Is it possible to do it using Webservice?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-17-2008, 01:48 AM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Re: Webservice and its uses

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-19-2008, 09:31 PM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Question Re: Webservice and its uses

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?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 03-20-2008, 09:49 PM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Re: Webservice and its uses

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?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 07:14 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0