Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

passing json parameter to asp.net web service

$
0
0

Hi,

I have successfully used asp.net web services of .NET 3.5 to retrieve a custom class instance. I am using google web toolkit, and I have seen posts from users claiming they have passed json between gwt and asp.net. The problem appears when I try to pass a parameter to asp.net web service. First I thought the problem was related to custom type, but it appears I can not even pass a simple string parameter. 

my outgoing json string is:

{"input":"testing call"}

 and the response I get is :

{"Message":"Invalid web service call, missing value for parameter: \u0027input\u0027.","StackTrace":"   at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n   at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n   at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}

 

The source code of the web service is below, and I'd really appreciate any help. I do not want to use jayrock etc, when .NET has a native solution for this purpose. 

 

Best Regards

Seref Arikan 

 

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;




namespace JsonTest
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [System.Web.Script.Services.ScriptService]
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {


        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public TestInfo HelloWorld()
        {
            return new TestInfo();
        }


        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public void TestHelloWorld(string input)
        {
            string val = input;
        }
    }


    public class TestInfo
    {
        public string val = "I am a test val";
        public int intVal = 2;
        public ArrayList lst = new ArrayList() { "val1", "val2" };
    }
}
   
 

 


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>