Hi
I'm able to work with class objects on the client and i want to send the array of class objects to the web service as parameter. Somehow i'm not able to get it work.. What should be the parameter declaration on the web service. can someone post the sample for this?
Thank You
Subba
this should work. Can past your code. i will take a look
Hi Raghu, here is my code snippets. Let me know if you need any more information.
Question is my class object and added the addtribute<GenerateScriptType(GetType(Question))>on the web service.
<WebMethod()> _
PublicFunction BuildQuestions(ByVal questionsTobeBuiltAs List(Of Question))AsString
Dim queryStringAsString =String.EmptyFor Each item As Question In questionsTobeBuilt
queryString = queryString & item.Content
Next
ReturnqueryString
EndFunction
on the client i'm adding the data in this way:
this._questions = new Object();
this._questions[data.Id] = {Question: data};
and my webservice call from client:
ASPNETFuturesDragDrop.QuestionareService.BuildQuestions(questonsToBeSubmitted, onBuilded);
//display the server-side response to the customer
function onBuilded(result) {//Sys.Preview.UI.Window.messageBox(result,Sys.Preview.UI.MessageBoxStyle.OK);
OutputMsg.innerHTML=result;
}
go through this forum, they discuss the same problem you are having. It is by design. Change your web method that takes array of your class instead of Generic List.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=90536&SiteID=1
Thanks for the link. i even tried with array of objects, Question() as parameter for the web service. that gives me an error 'System.MissingMethodException -- No parameterless constructor defined for type Question[]'. I donno where do i need to declared the constructor for an arrya of objects..
Mark Your WebService/WebMethod with the GenerateScriptType Atttribute with the Server Side Class then in the client Create a Array Like the following:
var q1 = new Question();
var q2 = new Question();
var q3 = new Question();
var q4 = new Question();
//Code to set the properties of the above questions
var questions = new Array();
questions.push(q1):
questions.push(q2):
questions.push(q3):
questions.push(q4):
//Then Call the WS with the array.
WS.SomeMethod(questions, successHandler);
No comments:
Post a Comment