Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 357461805F for ; Thu, 17 Dec 2015 05:10:07 +0000 (UTC) Received: (qmail 80511 invoked by uid 500); 17 Dec 2015 05:10:06 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 80438 invoked by uid 500); 17 Dec 2015 05:10:06 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 80426 invoked by uid 99); 17 Dec 2015 05:10:05 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Dec 2015 05:10:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 77067180502 for ; Thu, 17 Dec 2015 05:10:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.15 X-Spam-Level: *** X-Spam-Status: No, score=3.15 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 5VcpHJpNCrSG for ; Thu, 17 Dec 2015 05:09:55 +0000 (UTC) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 24BB3429C4 for ; Thu, 17 Dec 2015 05:09:55 +0000 (UTC) Received: by mail-pa0-f46.google.com with SMTP id jx14so6851503pad.2 for ; Wed, 16 Dec 2015 21:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=5ioCrHJwua4xv4EgK00ucgk1K/ZYrN0XCYp5+4THOkw=; b=pEC9GDqGis4hdbBoaH3X+jWS/shap7IYQHPvxEwBGiewKEDcKjpMeNDPRhBJ9owq0J sRyIxXbHO7zbzlsZ+2rtRmzuMltw7USfJxpYuiv46n2J8WjZp7UA1YyOuFdRmKZSRmBe x3Xa841V9t1vZs/9D1K+BIFJRjyJuD8QoJMXBDV6+XtK/FrFy1HSrekmwveo8FKiT11/ hvfbPr5K483qbRpoJGL/8wG1gVE8S0puGgqBm7UujqnrVPdTE2RuZMGER6+RLRI3GiAg 6JhN1utDBRyizFRS0G8Jnm+1XpIJAeQXr4l4DFyFG4ehH3J/6vNdU+C8I8LQpz6jBLP5 uRrg== MIME-Version: 1.0 X-Received: by 10.66.216.73 with SMTP id oo9mr69151046pac.148.1450328994366; Wed, 16 Dec 2015 21:09:54 -0800 (PST) Received: by 10.66.229.8 with HTTP; Wed, 16 Dec 2015 21:09:54 -0800 (PST) In-Reply-To: <56713BAC.5040302@gmail.com> References: <56713BAC.5040302@gmail.com> Date: Thu, 17 Dec 2015 11:09:54 +0600 Message-ID: Subject: Re: RS service method accepting 2 parameters From: Maxim Solodovnik To: users@cxf.apache.org Content-Type: multipart/alternative; boundary=001a11c21856844c6d052711086c --001a11c21856844c6d052711086c Content-Type: text/plain; charset=UTF-8 Hello Sergey, thanks for the quick response, maybe you have some example/test I can take a look at? cause currently I need to create methods like: Response resp = getClient(USER_SERVICE_URL) .path("/hash") .query("sid", r.getMessage()) .form(new Form().param("user", new JSONObject(user).toString()).param("options", new JSONObject(options).toString())); public static BeanA fromString(String s) { JSONObject o = new JSONObject(s); BeanA b = new BeanA(); b.prop1 = o.getString("prop1"); b.prop2 = o.getString("prop2"); b.prop3 = o.getString("prop3"); b.prop4 = o.getString("prop4"); return b; } in my beans, which I believe should be done somehow automatically without this code I'm getting Parameter Class org.apache.openmeetings.package.BeanA has no constructor with single String parameter, static valueOf(String) or fromString(String) methods On Wed, Dec 16, 2015 at 4:23 PM, Sergey Beryozkin wrote: > Hi Max > > It is unfortunate Form accepts parameters with String values, I think we > missed it should be Object instead given that ParamConverterProvider is > available in JAX-RS 2.0. > > form() can deal with MultipartMap - CXF ships MetadataMap which implements > it, and JAX-RS 2.0 ships a simple implementation too: > > > https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/core/MultivaluedHashMap.html > > You'll still need registering ParamConverterProvider if values are not > String and the beans do not override toString() > > HTH, Sergey > > > > > It has to be MultivaluedMap, JAX-RS > > On 16/12/15 10:04, Maxim Solodovnik wrote: > >> Hello All, >> >> I'm currently trying to write RS service accepting 2 objects of different >> types as parameters: >> >> ex. code: >> >> >> @WebService(serviceName="org.apache.openmeetings.webservice.UserWebService") >> @Features(features = "org.apache.cxf.feature.LoggingFeature") >> @Produces({MediaType.APPLICATION_JSON}) >> @Path("/user") >> public class UserWebService { >> @POST >> @Path("/hash") >> public ServiceResult getRoomHash( >> @FormParam("user") BeanA user >> , @FormParam("options") BeanB options >> ) throws ServiceException >> {} >> } >> >> and I'm trying to invoke this method from JUnit test: >> >> >> ExternalUserDTO user = new ExternalUserDTO(); >> RoomOptionsDTO options = new RoomOptionsDTO(); >> Map> map = new LinkedHashMap<>(); >> map.put("user", Arrays.asList((Object)user)); >> map.put("options", Arrays.asList((Object)options)); >> Response resp = getClient(USER_SERVICE_URL) >> .path("/hash") >> .form(map); >> //throws no body wrapper for LinkedHashMap class >> >> I cannot use .form(new Form().....) due to it can only accepts string >> parameters >> >> can someone please point me to an example or provide with the hint how >> this >> can be implemented >> >> Thanks in advance >> >> >> > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > -- WBR Maxim aka solomax --001a11c21856844c6d052711086c--