使用哪种Web服务进行复杂查询? [英] What web service to use for complicate query?

查看:54
本文介绍了使用哪种Web服务进行复杂查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个关于Web服务的幼稚问题.

A naive question about web service.

我需要实现一个复杂的查询.客户端需要将许多参数传递给服务器,服务器将发送回响应的许多数据字段.

I need to implement a complicate query. The client need to pass in many parameters to the server, and the server will send back response will many data fields.

哪种类型的Web服务适合于此?我知道RESTful POST方法旨在创建"对象,但是我可以使用POST来实现这一点吗?

What type of web service is suitable for this? I know that RESTful POST method is meant to "create" an object, but can I use POST for implementing this?

或者SOAP对此更好?

Or SOAP is better for this?

推荐答案

在这里.

//对于控制器

    public JsonResult GetData(string param1, string param2)            
    {
        List<YourModecClass> data = new List<YourlModelClass>();

            //Mockup data only...you should get the data from DB source
            data = new List<YourModelClass>();
            data.Add(new YourModelClass() { Region = "", Value_TY = 0});
            data.Add(new YourModelClass() { Region = "", Value_TY = 0 });
        return Json(data, JsonRequestBehavior.AllowGet);
     }

//jQuery

function getServerData() {
var entity = { 
    param1: param1 //--> ths is a variable
    param2: "value" //--> hardcoded
}
var parameter = JSON.stringify(entity); 

$.ajax({
    type: "POST",
    url: url + "/GetData",  
    data: parameter,
    dataType: "json",
    contentType: "application/json",
    async: true,
    beforeSend: function () {
    },
    success: function (response, status, xhr) {
        yourJavascriptVariable = response;
        doSomethingWithreceivedDataAbove();
    },
    error: function (xhr, status, error) {
        debugger;
    }
});

这篇关于使用哪种Web服务进行复杂查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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