的WebAPI批量请求 [英] webapi batch requests

查看:365
本文介绍了的WebAPI批量请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方式来批量请求到服务器。我发现一个帖子由布拉德·威尔逊概述了如何使用信息hanlder的 http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html#more 但我没能得到这方面的工作。

I am looking for a way to batch requests to the server. I found a post by Brad Wilson outlining how to make a batch handler using a message hanlder http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html#more but I wasn't able to get this working.

首先,我不得不编译错误,因为的WebAPI不明白路由专用终端处理器像使用布拉德的例子。也有与媒体类型和/或格式(不记得是哪)的问题。我的下一个尝试是使一批控制器。所以不是批量处理我有一个批量控制器。我几乎有这个工作,除了当我用MessageHandlerInvoker调用单个命令我得到了有关我已经regsstered额外的处理程序异常(1用于登录请求/响应,另一个模仿用户身份验证)。

first I had compile errors because webapi did not understand "route-specific endpoint handler" like Brad's example used. there were also problems with the media type and/or formatter (can't remember which). My next attempt was to make a batch controller. so instead of a batch handler I had a batch controller. I almost has this working except when I used the MessageHandlerInvoker to call the individual commands I got exceptions about the additional handlers I have regsstered (1 for logging request/response and another to mimic user authentication).

在这一点上我停了下来,恢复到个人的要求,不是很理想,但它的作品。

At that point I stopped and reverted back to individual requests, not ideal, but it works.

我的环境:


  • .NET 4.0

  • VS 2010

  • MVC 4前端(调用的WebAPI)

  • 的WebAPI作为一个服务层

任何人都有成批的与消息和任何的WebAPI成功?

Has anyone else had any success with batched messages and webapi?

推荐答案

要能够使用你需要的ASP.NET Web API RTM,当布拉德写的文章是昨天才发布了(当时每个路由处理器,它只用夜间MyGet饲料工作建立或反对codePLEX源)。

To be able to use per-route handlers you need ASP.NET Web API RTM which was only released yesterday (at the time when Brad wrote the article, it would only work with nightly MyGet feed builds or against Codeplex source).

您可以得到整个 MVC4 RTM这里或干脆关闭的NuGet。

You can get entire MVC4 RTM here or simply off Nuget.

这篇关于的WebAPI批量请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆