Sunday, March 11, 2012

passing json parameter to asp.net web service

When passing a string you actually passing an array of chars and therefore
your parameter should look like this

{"input":["testing call"]}

If you do not do so, the web method throws an exception because it receives a parameter of different
type than the expected one.


Hi,

Unfortunately, {"input":["testing call"]} does not change the response:


{"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"}


I don't see your client side call, but could the issue be that you are not passing the asynchronous client functions with the call to the web service proxy.

Example... Service1.HelloWorld(onCompletion, onTimeout, onError)

Where each of the parameters is a client side javascript function. I have not done this in ASP.NET AJAX as of yet, but what I just was learning said that you needed to reference the callbacks (of course one place said there was onCompletion and onError and the other had an additional onTimeout so YMMV).

I am more familiar with Jayrock, but looking to use the MS provided solution in the future.

Thanks.
Pete Gordon

No comments:

Post a Comment