简体   繁体   English

这是将数据(复杂数据/原始数据)发送到服务并获得响应(复杂数据/原始数据)的最佳方式(WCF或WEB API)

[英]Which is the best way (WCF or WEB API) to send data(complex data/primitive data) to a service and get the response(complex data/primitive data)

I have one scenario, Let Say A is a Web based Application and needs to show some data on screen based on data returned from component B. Now A send some data(which is going to be input parameter for a component B) on an event to B , and component B is going to do calculation on input parameter and return data to A. Both A and B are handled by different organization, So what is the best way to communicate between them, is WCF or WEB API(also suggest how can we implement this scenario)? 我有一个场景,假设A是一个基于Web的应用程序,需要根据从组件B返回的数据在屏幕上显示一些数据。现在A在事件中发送一些数据(将作为组件B的输入参数)到B,组件B将对输入参数进行计算并将数据返回给A。A和B都是由不同的组织处理的,所以它们之间最好的通信方式是WCF或WEB API(还建议如何我们可以实现这种情况吗?

I am thinking of creating Web API for component B here , so that A can consume that and call component B,and Transfer data in JSON format. 我正在考虑在此处为组件B创建Web API,以便A可以使用它并调用组件B,然后以JSON格式传输数据。 But the issue in this approach is that, this request is going to be GET Request, and we can't send complex types on GET request. 但是这种方法的问题在于,该请求将是GET Request,并且我们无法在GET Request上发送复杂的类型。 Even if we are communicating through JSON format, how can we send huge data in GET request.Please correct me if mine understanding is wrong. 即使我们通过JSON格式进行通信,也如何在GET请求中发送大量数据。如果我的理解错误,请更正我。

No of Input Parameter is ranging between 10 to 20 and number of request made to Component B is very much frequent, So we have to take care of performance as well. 输入参数的数量在10到20之间,并且对组件B的请求数量非常频繁,因此我们也必须注意性能。

Updatde 1: First Issue is we can't send data in Request Body for GET. 更新1:第一个问题是我们无法在GET的请求正文中发送数据。

Generally the question is WCF for complexity and security vs WebApi for simplicity and speed . 通常,问题是WCF for complexity and securityWebApi for simplicity and speed If WCF features are not required, I will go for WebApi. 如果不需要WCF功能,我将使用WebApi。 If you need to send complex data with request, you can use POST. 如果您需要发送带有请求的复杂数据,则可以使用POST。

It is perfectly correct to request data using POST, there are only small limitations. 使用POST请求数据是完全正确的,只有很小的限制。
Look here: https://www.w3schools.com/jquery/jquery_ajax_get_post.asp 看这里: https : //www.w3schools.com/jquery/jquery_ajax_get_post.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM