c# - POST Multiple Parameters to WCF Service -


i'm trying understand wcf, questions may dumb. believe have firm understanding of "get" operations. i'm working on "post" operations. question is, can write wcf service operation, webinvoke, accepts multiple parameters? or, when post data, accept single serialized parameter?

thank you!

yes, post have passed in using common understanding of data, aka "data contract".

in wcf, typical approach here you'd create contract class (just off-my-head example, not 100% working))

[datacontract(namespace="http://yournamespace.com")] public class mycontract {    [datamember(order=1)]    public string mydata1 { get(); set{};}     [datamember(order=2)]    public string mydata2 { get(); set{};}  } 

then you'd specify wcf operation accept contract type parameter

[webinvoke(method="post")] public string dosomethingfrompost(mycontract posteddata) { } 

on client, you'd serialize data xml/json matches contract. again, loose example:

<mycontract xmlns="http://yournamespace.com"> <mydata1>value</mydata1> <mydata2>value</mydata2> </mycontract> 

when contract matches, wcf deserialze post contract object, @ point can use other class.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -