Microsoft had created some great tutorial videos for asp.net. This one starts by talking you through the default / template "Hello World" webservice within VS2005.
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
//Links on WSDL FYI
//http://www.w3.org/TR/wsdl
//http://www.w3schools.com/wsdl/default.asp
namespace WebServiceCSharp
{
///
/// Web service class Service1 with attributes describing the service and its binding.
///
[WebService(Namespace = "http://howdoi.org/", Description = "This is a sample service for How Do I videos.", Name = "MyService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
///
/// Simple web method w/o parameters that returns a string.
///
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
In the video he example the use of the above WebService, WebServiceBinding, WebMethod attributes. Next he starts /tests this basic webservice (as shown in the screen shot) from Solution Explorer, right click on .asmx file and choose "view in browser".
From here VS will create a test page (http://localhost:/Service1.asmx)
From here there is a link to invoke / test the HelloWorld method within our service (http://localhost:/Service1.asmx/HelloWorld)
This returns an xml version of HelloWorld:
No comments:
Post a Comment