Problem Description


AJAX Javascript call to web service fail with is ‘null or not an object’ , when Web service is placed into sub directory say Service



A Runtime Error has occured

Do you Wish to debug?


Error: 'SupportIssue.BrokenService' is null or not an object


Web service code


namespace SupportIssue


[WebService(Namespace = "")]


public class WorkingService : System.Web.Services.WebService



        public string HelloWorld()


            return "Hello World";





In Default.aspx, registering through Script manager


<asp:ScriptManager ID="ScriptManager1" runat="server">


            <asp:ServiceReference Path="~/WorkingService.asmx" />

           <asp:ServiceReference Path="~/services/BrokenService.asmx" />




Calling the web service method in Javascript in Default.aspx


<script language="javascript" type="text/javascript">

            //This works because it is in the same directory

var x = SupportIssue.WorkingService.HelloWorld(OnSucceeded, OnFailed);

//The following line break in to error!!!

var y = SupportIssue.BrokenService.HelloWorld(OnSucceeded, OnFailed);

            function OnSucceeded(result, userContext, methodName)




            function OnFailed(error, userContext, methodName)






The above line would fail as the web service has been placed in sub directory called services

Same line would succeed if we put out web service (.asmx) file in application Root Folder


-- Tracking through Fiddler trace, notice we are making call to jsdebug


Note : The "/jsdebug" suffix is used by AJAX to get the debug release of Javascript proxy for web service and "/js" for released version


For GET /SupportIssue/WorkingService.asmx/jsdebug HTTP/1.1


HTTP/1.1 200 OK

For GET /SupportIssue/Service/BrokenService.asmx/jsdebug HTTP/1.1


HTTP/1.1 500 Internal Server Error


-- Checking IIS log we got 500

2008-04-26 05:59:02 W3SVC1 GET /SupportIssue/Service/BrokenService.asmx/jsdebug - 80

FAREAST\jaskis 500 0 0


-- Try Browsing jsdebug for failed request from IE



Server Error in '/SupportIssue' Application.


No web service found at: /SupportIssue/Service/BrokenService.asmx.

Exception Details: System.InvalidOperationException: No web service found at: /SupportIssue/Service/BrokenService.asmx.





1) Issue seems to be with Web application project and not for Web site, because for WAP Namespaces are added for before class beginning so use Web Site project instead

For example

namespace SupportIssue


public class WorkingService.....



2) If want to use WAP then change the namespace of classes within the sub directory corresponding to sub directory name only*

Directory/folder Name = Service

As default setting we have namespace(project name) added for WAP

namespace SupportIssue




Change it to

namespace SupportIssue.Service




var y = SupportIssue.BrokenService.HelloWorld(OnSucceeded, OnFailed);


var y = SupportIssue.Services.BrokenService.HelloWorld(OnSucceeded, OnFailed);

That’s it.

Hope it helps :-)