It looks like you are not specifying where the parameters should come from.
Are they path params, form params, or do they come from headers?  If these
are form params, try something this:

String sayHello(@FormParam("pmsg") String pmsg, @FormParam("pval") String
pval);

Josh

On Wed, Mar 31, 2010 at 5:11 PM, atest12 <ariela...@yahoo.com> wrote:

>
> Hello,
>
> I have following class using JAX-RS for restful web services. I want to
> pass
> multiple parameters to a post method.
> However, the values from the client call only populates the first parameter
> i.e. pmsg and not the pval parameter.
>
> @Path("/helloWorldService/")
> @WebService(serviceName = "HelloWorld", name = "HelloWorldService",
> targetNamespace = "http://mylocal/test/HelloWorldService";)
> public interface HelloWorldService {
>
>        @WebMethod
>        @POST
>        @Path("/sayhello")
>        String sayHello(String pmsg, String pval);
>
> }
>
> What is wrong with this annotation? Am I missing anything?
>
> In my Tomcat server, Palyoad shows this value:
>
> pmsg=adam&pval=smith
>
> but in my implemented class only pmsg is populated and pval is null.
>
> This is my client call. Am I calling it incorrectly?
>
> URL u = new
> URL("http://localhost:8080/My.WebServices/rest/helloWorldService/sayhello
> ");
>                        String[] paramName = new String[] { "pmsg", "pval"
> };
>                        String[] paramVal = new String[] { "adam", "smith"
> };
>                        HttpURLConnection conn = (HttpURLConnection)
> u.openConnection();
>                        conn.setRequestMethod("POST");
>                        conn.setDoOutput(true);
>                        conn.setDoInput(true);
>                        conn.setUseCaches(false);
>                        conn.setAllowUserInteraction(false);
>                        conn.setRequestProperty("Content-Type",
> "application/x-www-form-urlencoded");
>
>                        OutputStream out = conn.getOutputStream();
>                        Writer writer = new OutputStreamWriter(out,
> "UTF-8");
>                        for (int i = 0; i < paramName.length; i++) {
>                                writer.write(paramName[i]);
>                                writer.write("=");
>                                writer.write(URLEncoder.encode(paramVal[i],
> "UTF-8"));
>                                writer.write("&");
>                        }
>                        writer.close();
>                        out.close();
>
>                        BufferedReader rd = new BufferedReader(new
> InputStreamReader(conn
>                                        .getInputStream()));
>                        StringBuilder sb = new StringBuilder();
>                        String line;
>                        while ((line = rd.readLine()) != null) {
>                                sb.append(line);
>                        }
>                        rd.close();
>
>                        conn.disconnect();
>                        System.out.println(sb.toString());
>
> Thanks.
>
>
> --
> View this message in context:
> http://old.nabble.com/Passing-multi-parameters-to-a-post-RESTful-call-tp28103206p28103206.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Reply via email to