C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Creating simple Web Services using C# web Application:


Posted Date: 06 Oct 2008    Resource Type: Articles    Category: WCF/Webservices

Posted By: Dharani Devi       Member Level: Bronze
Rating:     Points: 10



Hi,I think that Most of us know the Webservice,this is for to those who are not familiar with the Webservices.

Create a new Project and select Add New WebService in
New Project Template .

Create a New Service.asmx File for your Webservice.
You ll get a default method in your Code behind file of Service.asmx .i.e)Hello World Method

Service.cs
================

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}

}


After writing the Service Press F5 to run this service.
You ll get a result page with your method name,after clicking the method name(Hello World) you ll redirect to a page.
Just copy that URL from ur browser for eg:(http://localhost:1849/SampleService/Service.asmx?op=HelloWorld) ,which ll be used in your Application

Now the Web Service Creation ll be over

Next Step:
Creata a New Asp.net Web Application,Right Click From your Solution Explorer,Click on Add new WebReference folder,You ll get a template and just paste ur Service URL in that addressbar
and click on OK button.

Service Related Files ll be added in your Project.Now create a new webForm,and In your codebehind,
Include the namespace for Your Service,and create object for your Service Class and call ur method,For eg:

Check.cs
=================

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using localhost;//this is your service namespace


public partial class Check : System.Web.UI.Page
{
Service ser = new Service();
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(ser.HelloWorld());//You ll get a "HelloWorld " string as a result.
}


}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Webservices using C#  .  Webservice in web application  .  Web Services  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: J2EE and Microsoft .NET for Enterprise Applications
Previous Resource: Asynchronous Web Service in .NET
Return to Discussion Resource Index
Post New Resource
Category: WCF/Webservices


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use