1
WCFでPOSTデータを取得するのはうんざりです(私は初心者です)ので、何が間違っているのか分かりません。私はこのフォームでPOSTデータを送信しようとしている:WCFサービスアプリケーションでフォームからPOSTデータを取得する
<!doctype html>
<html>
<head></head>
<body>
<form action='http://localhost:56076/Service.svc/invoke' method="post" target="_blank">
<label for="firstName">First Name</label>: <input type="text" name="firstName" value="" />
<label for="lastName">Last Name</label>: <input type="text" name="lastName" value="" />
<input type="submit" />
</form>
</body>
</html>
そして、私は(VS2008で)WCFサービスアプリケーションを使用しています:
//IService.cs: [ServiceContract] public interface IService { [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "invoke", BodyStyle = WebMessageBodyStyle.WrappedRequest)] string GetData(Stream aoInput); }
//Service.svc.cs public class Service : IService { public string GetData(Stream aoInput) { using (StreamReader loReader = new StreamReader(aoInput)) { string body = loReader.ReadToEnd(); var @params = HttpUtility.ParseQueryString(body); return @params["FirstName"]; } } }
私は上の送信]を押した後、サービスの実行中私のコード内のブレークポイントからの応答はありません。私は間違って何をしていますか?
POST操作を実行すると、私が間違っていないと評価されたqueryStringsはありません。したがって、返信はありません。 POST中のパラメータはRequestBodyの一部であり、クエリ文字列ではありません – Rajesh