c# 4.0 - What does my WCF service expect the request data to look like? -


i've got wcf-hosted service right self-hosted , defined this:

[operationcontract] [webinvoke(requestformat = webmessageformat.json, method = "put", uritemplate = "/device")] void updatedevicelevel(zdevice device); 

the zdevice class looks this:

public class zdevice {     public bool? newpowerstate { get; set; }     public int nodeid {get; set;} } 

i have simple mac client consumes service using http post. posts {"newlevel":27,"nodeid":6} \devices url , .net magically stuffs values zdevice object me. here.

now however, need add basic security mix. i've done adding new parameter , "requestwrapping" method call:

[operationcontract] [webinvoke(requestformat = webmessageformat.json, bodystyle=webmessagebodystyle.wrappedrequest, method = "put", uritemplate = "/device")] void updatedevicelevel(string password, zdevice device); 

what i'm trying figure out syntax server expecting consuming clients. i'd hoped posting in {"password":"somepwd", "newlevel":27,"nodeid":6} work, .net no longer able "deserialize" zdevice object did before.

anyone got suggestions me?

thanks

it should this:

{"password":"somepwd", "device": {"newlevel":27,"nodeid":6}} 

each property on json object has value; , in case of device it's new object.

note in zdevice class called newpowerstate, in json calling newlevel. in class it's bool, in json assigning int. isn't matching up.

based on c#, i'd expect this:

{"password":"somepwd", "device": {"newpowerstate":true,"nodeid":6}} 

the property names in json object should match parameter / property names in c#.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -