[WebInvoke(Method = "PUT", UriTemplate = "users/{username}")]
[OperationContract]
void PutUser(string username, User newValue);//update a user
我有一個更新用戶方法定義如上所示。然後我使用HttpWebRequest來測試這個方法,但是我怎麼能通過這個HttpWebResquest傳遞User對象呢? 以下代碼是我到目前爲止得到的。傳遞對象與WCF RESTful
string uri = "http://localhost:8080/userservice/users/userA";
HttpWebRequest req = WebRequest.Create(uri) as HttpWebRequest;
req.Method = "PUT";
req.ContentType = " application/xml";
req.Proxy = null;
謝謝你的提示 – 2009-10-12 06:41:42