in the current situation, when we post data from a webpage via the Jquery Ajax post to a webservice, we build a Json string with two or three parameters and we have a webservice with a method that accepts that same (named) parameters.
But now i have an object in my javascript with 10 properties and i was wondering if i can post that entire object to my webservice.
I’ve tried posting the object and have an type ‘Object’ parameter in the webservice, but that didn’t work.
Yes, this is possible. You need to create a class and make it serializable by using the DataContract attribute. You then use DataMember to mark the members of the class to be serialized. Something like this will do:
Then in your WCF service:
In the client code, do something like this: