我有现在一个WCF托管服务,这是自托管和定义如下:我的WCF服务期望请求数据的外观如何?
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, Method = "PUT", UriTemplate = "/device")]
void updateDeviceLevel(ZDevice device);
的ZDevice类看起来是这样的:
public class ZDevice {
public bool? newPowerState { get; set; }
public int nodeId {get; set;}
}
我有一个简单的Mac客户端它通过使用http post来使用该服务。它张贴{"newLevel":27,"nodeId":6}
到\devices
url和.NET神奇地将这些值填充到ZDevice对象中。一切都很好。
但是,现在我需要为混合添加一些基本的安全性。我已通过添加新的参数和一些“RequestWrapping”的方法调用做到了这一点:
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, BodyStyle=WebMessageBodyStyle.WrappedRequest, Method = "PUT", UriTemplate = "/device")]
void updateDeviceLevel(string password, ZDevice device);
我试图现在要做的是找出语法服务器从客户的消费预期。我希望在{"password":"somepwd", "newLevel":27,"nodeId":6}
的帖子能够发挥作用,但.NET不再像以前那样将其“反序列化”到ZDevice对象中。
有人对我有一些建议吗?
感谢
DOH!我以为我曾尝试过,但我做了“zdevice”而不是“设备”。谢谢! – bugfixr
另外感谢 - 我在创建我的问题时混淆了一些代码。无需花时间查看,即可快速为我发布信息。 – bugfixr