简体   繁体   中英

how to build web service that get post method

我经常从iPhone向Web服务发送包含所有数据的URL,我想知道是否有任何方法可以通过使用post方法发送此数据来获取这些东西。

since you don't give much detail on your needs, or what you have, I'll give you some broad resources:

Consuming WCF / REST service using JQuery ajax post

WebInvoke Method=“POST” or "GET" for a REST Service on WCF

Get raw xml from POST method in service implemented using WCF WebHttp API

If you need more specific help, please include more details regarding your needs and what code you have now.

I personally find MVC to provide a nice and organized way of publishing REST APIs. for example if you want a REST method that returns the time base on an offset on post you would create something like this

public class TimeController: Controller
{
        [HttpPost]
        public JsonResult GetTime(int offset)
        {
           return new JsonResult { Time= DateTime.Now().AddHours(offset) };
        }
}

you can access that action if you post to http://appurl/TimeController/GetTime

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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