I'd bear in mind that it's often best to keep your web services seperate from the pages that call them.
To create a simple web service in an aspx file, you'd use something like this:
<%@ WebService Language="C#" Class="MyWebService" %>
using System;
using System.Web;
using System.Web.Services;
[WebService(Namespace = "http://www.example.com/webservices/MyWebService, Description = "My Web Service")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MyWebService : WebService
{
[WebMethod(Description = "Add two numbers and return the result.")]
public int AddNumbers(int first, int second) {
return first + second;
}
}
If you are looking for solid cross platform dynamic JavaScript component which can talk to your web service I'd check out http://www.guru4.net/articoli/javascript-soap-client/en/ (I use this and highly recommend it).
Alternatively, you could use something like jQuery to access the REST interface, or parse the XML from the SOAP response yourself.