Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将值列表作为参数发送_Java_Web Services_Rest_Soapui - Fatal编程技术网

Java 将值列表作为参数发送

Java 将值列表作为参数发送,java,web-services,rest,soapui,Java,Web Services,Rest,Soapui,我使用SoapUi来测试我的web服务。我想从SoapUi发送post方法的参数列表。这是我想要处理列表但不起作用的代码,我得到一个空指针异常: @POST @Produces(MediaType.APPLICATION_JSON) @Path("/subscribeList") public Response subscribe( final MultivaluedMap<String, String> listoffields ) { S

我使用
SoapUi
来测试我的web服务。我想从SoapUi发送
post
方法的参数列表。这是我想要处理列表但不起作用的代码,我得到一个
空指针异常

   @POST
   @Produces(MediaType.APPLICATION_JSON)
   @Path("/subscribeList")
   public Response subscribe( final MultivaluedMap<String, String> listoffields )
   {
      System.out.println( "The list has: " + listoffields.size() );
      return Response.ok().build();
   }
@POST
@产生(MediaType.APPLICATION_JSON)
@路径(“/subscribeList”)
公共响应订阅(最终多值DMAP列表字段)
{
System.out.println(“列表有:“+listofelds.size()”);
返回Response.ok().build();
}
soapui
我将参数作为
queryparam
发送。 有人能帮我解决这个问题并发送一个列表吗?

作为方法参数注入,并使用
UriInfo.getQueryParameters()获取映射


您的输入是什么?您的邮件正文?我只是从
soapui
http://localhost:8888:/service/subscription/subscribeList?name=name5&age=age5
您的意思是说,您需要名称和年龄作为多值Map ListoFields的一部分吗?我只想将字段
name
age
作为列表传递,没有分隔的值。我也尝试过使用
FormParam
,但我得到了
未知的媒体类型
public Response subscribe( @Context UriInfo uriInfo ) {
    MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
    String name = queryParams.getFirst("name");
}
public Response subscribe( @QueryParam("name") String name,
                           @QueryParam("age") int age ) {