Having some trouble making a call to an ASP.NET web service from Javascript here. No matter how I fully qualify the name, it just won't recognize the Web Method - trying to troubleshoot this.
Snippet of my web.config file:
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
Next up is the web service declarations:
[WebService(Namespace = "http://tempuri.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class SavingService : System.Web.Services.WebService
{
[WebMethod]
public static void SaveToDB(string runCode, string container,
string productType, string inspector, string[][] scoregrid, string notes)
JavaScript code (QCApp4 represents the project's namespace):
function PrepToSave()
{
....
QCApp4.SavingService.SaveToDB(codev, containerv, prodtype, inspector, scoregrid, notes);
}
On the javascript side, scoregrid is set as a jagged 2d array using Array(). This seemed to be the only concern with the parameters for the web service.
Lastly, the service reference:
<asp:ScriptManager id="scriptmng" runat="server">
<Services>
<asp:ServiceReference Path="~/SavingService.asmx" />
</Services>
</asp:ScriptManager>
Encountering errors whether calling the web method directly, through SavingService.SaveToDB, or with full qualifiers. The error message points out that SaveToDB isn't defined, and similar issues with the other parts of the qualified name depending on what's entered first.
Could I be overlooking something? Any incorrect settings on my end?
Realized the WebMethod was set as static which caused more problems, currently seeing this in the error console:
Error: [Exception... "'Sys.Net.WebServiceFailedException: Sys.Net.WebServiceFailedException: The server method 'SaveToDB' failed with the following error: System.NullReferenceException-- Object reference not set to an instance of an object.' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "" data: no]