I got a problem when call spring.net web service from JQuery with POST method.
Here is the WebService code:
And it is configured to TestService.asmxCode:namespace SprintWS.WS { public interface ITestWS { string GetMessage(); string GetMessage2(string title, string content); } public class TestWS : ITestWS { private string message; public string Message { set { message = value; } } public string GetMessage() { return this.message; } public string GetMessage2( string title, string content) { return title + ":" + content; } } }
If I call it in this way, it works well:
And this also works:Code:function TestWebService2() { //TestService.GetMessage2("t", "c"); //alert("abc"); $.ajax({ //type: "POST", url: "TestService.asmx/GetMessage2?title=123&content=abc", //contentType: "application/json", //data: "{title:123,content:ccc}", //dataType: "xml", success: TestSuccess2, error: TestError }); } function TestSuccess2(result) { alert(result.text); } function TestError2() { }
But when I call method with parameters, like GetMessage2 with POST method. Like this:Code:function TestWebService() { //alert("abc"); $.ajax({ type: "POST", url: "TestService.asmx/GetMessage", //contentType: "application/json", data: "{}", //dataType: "xml", success: TestSuccess, error: TestError }); } function TestSuccess(result) { alert(result.text); } function TestError( error) { }
Problem occurs.Code:$.ajax({ type: "POST", url: "TestService.asmx/GetMessage2?title=123&content=abc", //contentType: "application/json", data: {title:123,content:ccc}, //dataType: "xml", success: TestSuccess2, error: TestError });
I got http response like this:
Does any one knows how to solve this problem?Code:System.InvalidOperationException: Missing Parameter: title。 在 System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) 在 System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) 在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() 在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
Thanks, adun.


Reply With Quote