You are not Logged in
Would you like to Login or Register

Today is: Friday, 21 November, 2008
Check this months hot topics

Web service calls from javascript using ATLAS (part 1)

ATLAS provides a fantastic mechanism for making web service calls from javascript code.

Take the simple web service below...

public class myWebService : System.Web.Services.WebService
{
    public myWebService () {
    }

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

You need to add reference to this web service to your ASP.NET page. This is achieved using the ScriptManager tag as in the example below...

<atlas:ScriptManager ID="myScriptManager" runat="server" EnablePartialRendering="true" >  
  <Services>        
    <atlas:ServiceReference Path="~/myWebServiceURL.asmx" />    
  </Services>
</atlas:ScriptManager>

Infact only the Services and ServiceReference elements are added to the basic scriptManager tag. Note taht there seems to be a limitation in the CTP that I am using where the web service needs to be in the same web site as your project. This is a serious limitation but it shouldn't be too hard to create a proxy for any web service runing elsewhere until this is fixed in the next CTP.

You can now make JavaScript calls to the web service as shown below...

<SCRIPT language='javascript'>
  myWebService.myWebMethod(s,myWebMethod_callback);

  function myWebMethod_callback(result)
  {
    alert("result="+result);
  }
</SCRIPT>

I hope you find the example useful in your own applications.

kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks
Dave Howard Skype
Author : Dave Howard
Published : Friday, 25 August, 2006

I have been involved in IT development for the last 10 years - a lot of it around desktop applications and telecoms.

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views