简体   繁体   English

如何通过清单 <int> Web Api C#上SOAP UI的参数

[英]How to Pass List<int> parameter to SOAP UI on a Web Api C#

I have a WebApi with something like this 我有一个像这样的WebApi

public HttpResponseMessage Get(List<int> Ids)
{
    //do some stuff with the List
}

I don't know if I have to do it POST because of that list or if I can use Get and recieve a list of int, I'm using SOAP UI here is a SS. 我不知道是否由于该列表而必须执行POST,或者是否可以使用Get并接收一个int列表,所以我使用的是SOAP UI。

SOAP UI屏幕截图

As far as the code is concerned, you should consider the following... 就代码而言,您应该考虑以下内容...

FromUri: FromUri:

[HttpGet]
public HttpResponseMessage GetListFromUri([FromUri] List<int> ids)
{
   //do some stuff with the List
}

FromBody: FromBody:

[HttpPost]
public HttpResponseMessage GetListFromBody([FromBody] List<int> ids)
{
   //do some stuff with the List
}

Also have a look at how parameter binding works in Web Api. 还可以看一下Web Api中参数绑定的工作方式。

https://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api https://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api

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

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