Web service calls from javascript using ATLAS (part 2) - Complex return types

Following on from part one which showed how to make web service calls from javscript, this article will now show the flexibility of the ATLAS framework by calling a web service that returns an object from javascript.

Lets expand from the previous example with the web service below...

public class myReturnClass
    public myReturnClass(){

    private string _myProperty1;

    public string myProperty1
        get { return _myProperty1;}
        set { _myProperty1 = value;}

    private string _myProperty2;

    public string myProperty2
        get { return _myProperty2;}
        set { _myProperty2 = value;}

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

    public myReturnClass myWebMethod() {
        myReturnClass o = new myReturnClass();
        o.myProperty1 = "a value";
        o.myProperty2 = "another value";
        return o;

You need to add reference to this web service to your ASP.NET page. This is achieved in exactly the same way as before...

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

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

<SCRIPT language='javascript'>

  function myWebMethod_callback(result)

I was very impressed that the properties of the c# class are now available to me in javascript. I hope you are too.

I have to say, credit goes to Paul Hayman who originally pointed this out to me. Credit also to the ATLAS team of course!

Author Dave Howard

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

Add Comment


Your comment has been received and will be shown once it passes moderation.