我確實有一個WCF RESTful .NET 4.0服務,它從URI的主體運行和使用值#Json。WCF REstful Service在Uri上傳遞用戶和密碼
我調用我的方法的方法如下:
利用海報,爲POST請求 http://localhost:25512/JSONService1.svc/CreateItem
身體:
= YOLO
工作正常!
,但我想消費的URI爲好,
http://localhost:25512/JSONService1.svc/CreateItem?uid=aaa&pass=111
這裏是我的代碼
這是Service1.cs
[OperationContract]
[WebInvoke(UriTemplate = "CreateItem", // ISSUES <<< not sure what to do here
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, Method = "POST")]
void CreateItem(Stream streamOfData,string uid, string pass);
,這與相關的代碼它,Service1.svc.cs
public void CreateItem(Stream streamOfData, string uid, string pass)
{
StreamReader reader = new StreamReader(streamOfData);
String res = reader.ReadToEnd();
NameValueCollection coll = HttpUtility.ParseQueryString(res);
}
你是什麼意思「我想消耗uri」? –
也許我應該稱之爲URL而不是URI,我想要傳遞/使用「uid和pass」參數並在CreateItem方法中使用它們 – HoneyDipper
好的,所以你想知道客戶端發送請求時實際的URI是什麼? –