D'oh!  It always works that way. Send off the message right before you find
the obvious.

I was looking at the final error message, not the stack trace.  In fact the
method was found but had thrown an Exception.  Sorry about that.

But the ultimate question of why do I need to have the demarshaller when CXF
can marshall the Collection fine still stands.

Thanks,
Linus


-----Message d'origine-----
De : Linus Kamb [mailto:[email protected]] 
Envoyé : Thursday, September 10, 2009 10:40 AM
À : [email protected]
Objet : fromString() not found

Hi,

 

I am new to CXF, so I apologize if this is obvious and I've missed it in the
docs.

 

First, what I am trying to do is POST JSON to a RS service.  And I've made
that work, although it seems awkward.  I'll get to that.

 

I have services defined:

 

      // @Produces({"application/json", "text/javascript"})

      @POST

      @Path("/add") 

      public Response addUnids(@QueryParam("userId")String userid,

                              @FormParam("unids")UnidCollection unids) {

            [..]

            return Response.ok().build();

      }

      @Produces({"application/json", "text/javascript"})

      @GET

      @Path(("/get")

      public Response getUnids(@QueryParam("userId") String userId) {

            return Response.ok(buildUnidCollection()).build();

      }

 

The immediate question is:

 

I have two classes:  Unid, and UnidCollection.  The latter simply contains a
Collection of the former.

 

Both have public static <type> fromString(String str) methods  (as well as
public static valueOf(String) methods).

 

However, when I invoke the service, I get an exception saying the
UnidOridCollection does not have String constructor, fromString or valueOf
methods. In fact it has both.    If I add the String constructor to
UnidCollection, it's happy.  But I'd prefer not to go that route.

 

Why does it find the fromString() in Unid, but not in UnidCollection() ?

 

The bigger question I have is why is CXF able to automatically marshall to
JSON, but not the other way around?

What is it that I need to do to make that automatic (and not need the above
methods)?

 

Thanks so much, 

Linus

 



Reply via email to