You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Jungwoo Jang <ju...@hotmail.com> on 2010/04/12 19:39:53 UTC

Question about ClientProxyImpl

Hello all,

I apologize in advance if this is the incorrect mailing list to post this question to.

I have a question around whether some behavior I am seeing is a bug or if it is functioning as designed.

I am trying out the parameter bean example in the cxf jaxrs documentation.  Note the following has been simplified, since I am only worried about @FormParam types.
@Path("/customer/{id}")
public class CustomerService {

    @POST
    public Response addCustomerOrder(@FormParam("") OrderBean bean) {
        ...
    }
}

public class OrderBean {
   public void setId(Long id) {...}
   public void setWeight(int w) {...}  
}

So, this works when I use a browser as the client.
But when I use the client runtime library it does not.

    CustomerService service = JAXRSClientFactory.create(...);
    service.addCustomerOrder(new OrderBean(123, 150));

After debugging through the code, it seems like the rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java's handleForm(...) method is doing something it shouldn't be doing.

    FormUtils.addPropertyToForm(form, p.getName(), params[p.getIndex()].toString());

The params[p.getIndex()] is the OrderBean that I have passed in.  But then this code converts it to a String and then in the 
FormUtils.addPropertyToForm method, it makes an InjectionUtils.extractValuesFromBean(value, "") call, where the value is the toString() value of the OrderBean.

So, the http request has bytes=somebytes, when I was expecting id=123 and weight=150.
                               
Here is the jira ticket that I believe was why this code was introduced.  https://issues.apache.org/jira/browse/CXF-2389?page=com.atlassian.jira.plugin.ext.subversion%3Asubversion-commits-tabpanel

So, is this bug?  I did a search for jira tickets to see if this was already a known issue. If it is a bug, should I file a new jira ticket and link it to the ticket mentioned above?

Thanks,
Jungwoo
 		 	   		  
 		 	   		  
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. 
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

Re: Question about ClientProxyImpl

Posted by Sergey Beryozkin <sb...@gmail.com>.
there was a regression indeed - I fixed it, with tests added

cheers, Sergey

On Tue, Apr 13, 2010 at 6:30 PM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi
>
> I'm not sure where a regression might've been introduced but I'll
> investigate. I think I have a test for proxies using query and path param
> beans, but no form param beans
>
> cheers, Sergey
>
>
> On Mon, Apr 12, 2010 at 11:54 PM, Josh Cummings <jo...@gmail.com>wrote:
>
>> For what it is worth, we experienced the same thing.
>>
>> We originally had only one method:
>>
>>    @POST
>>    @Path("/myResource/{c}/{d}")
>>    @Consumes({"application/x-www-form-urlencoded"})
>>    public E getE(@FormParam("") A a, @PathParam("") B b);
>>
>> We had client Java code and form posts using the one method.  Upon
>> upgrading
>> to 2.2.7, it appears that the handleForm method gets the String name of
>> our
>> object instead of the object itself.
>>
>> The workaround that we found was to split the code into two methods:
>>
>>    @POST
>>    @Path("/myResource/{c}/{d}")
>>    @Consumes({"application/xml", "application/json"})
>>    public E getE(A a, @PathParam("") B b);
>>
>>    @POST
>>    @Path("/myResource/{c}/{d}")
>>    @Consumes({"application/x-www-form-urlencoded"})
>>    public E getEForm(@FormParam("") A a, @PathParam("") B b);
>>
>> I'm also not certain if this is a bug.
>>
>> Thanks,
>> Josh
>>
>>
>> On Mon, Apr 12, 2010 at 11:39 AM, Jungwoo Jang <jungwoo3687@hotmail.com
>> >wrote:
>>
>> >
>> > Hello all,
>> >
>> > I apologize in advance if this is the incorrect mailing list to post
>> this
>> > question to.
>> >
>> > I have a question around whether some behavior I am seeing is a bug or
>> if
>> > it is functioning as designed.
>> >
>> > I am trying out the parameter bean example in the cxf jaxrs
>> documentation.
>> >  Note the following has been simplified, since I am only worried about
>> > @FormParam types.
>> > @Path("/customer/{id}")
>> > public class CustomerService {
>> >
>> >    @POST
>> >    public Response addCustomerOrder(@FormParam("") OrderBean bean) {
>> >        ...
>> >    }
>> > }
>> >
>> > public class OrderBean {
>> >   public void setId(Long id) {...}
>> >   public void setWeight(int w) {...}
>> > }
>> >
>> > So, this works when I use a browser as the client.
>> > But when I use the client runtime library it does not.
>> >
>> >    CustomerService service = JAXRSClientFactory.create(...);
>> >    service.addCustomerOrder(new OrderBean(123, 150));
>> >
>> > After debugging through the code, it seems like the
>> >
>> rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java's
>> > handleForm(...) method is doing something it shouldn't be doing.
>> >
>> >    FormUtils.addPropertyToForm(form, p.getName(),
>> > params[p.getIndex()].toString());
>> >
>> > The params[p.getIndex()] is the OrderBean that I have passed in.  But
>> then
>> > this code converts it to a String and then in the
>> > FormUtils.addPropertyToForm method, it makes an
>> > InjectionUtils.extractValuesFromBean(value, "") call, where the value is
>> the
>> > toString() value of the OrderBean.
>> >
>> > So, the http request has bytes=somebytes, when I was expecting id=123
>> and
>> > weight=150.
>> >
>> > Here is the jira ticket that I believe was why this code was introduced.
>>  https://issuesowever,
>> > .
>> apache.org/jira/browse/CXF-2389?page=com.atlassian.jira.plugin.ext.subversion%3Asubversion-commits-tabpanel
>> <
>> https://issues.apache.org/jira/browse/CXF-2389?page=com.atlassian.jira.plugin.ext.subversion%3Asubversion-commits-tabpanel
>> >
>> >
>> > So, is this bug?  I did a search for jira tickets to see if this was
>> > already a known issue. If it is a bug, should I file a new jira ticket
>> and
>> > link it to the ticket mentioned above?
>> >
>> > Thanks,
>> > Jungwoo
>> >
>> >
>> > _________________________________________________________________
>> > The New Busy think 9 to 5 is a cute idea. Combine multiple calendars
>> with
>> > Hotmail.
>> >
>> >
>> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
>> >
>>
>>
>>
>> --
>> Josh Cummings
>> The Pi-Dye T-Shirt Shop
>> http://www.pidye.com
>> 801-556-2751
>>
>> Learn how to be a part of the biggest redistribution of pi in the history
>> of
>> mankind at www.pidye.com
>>
>
>

Re: Question about ClientProxyImpl

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

I'm not sure where a regression might've been introduced but I'll
investigate. I think I have a test for proxies using query and path param
beans, but no form param beans

cheers, Sergey

On Mon, Apr 12, 2010 at 11:54 PM, Josh Cummings <jo...@gmail.com>wrote:

> For what it is worth, we experienced the same thing.
>
> We originally had only one method:
>
>    @POST
>    @Path("/myResource/{c}/{d}")
>    @Consumes({"application/x-www-form-urlencoded"})
>    public E getE(@FormParam("") A a, @PathParam("") B b);
>
> We had client Java code and form posts using the one method.  Upon
> upgrading
> to 2.2.7, it appears that the handleForm method gets the String name of our
> object instead of the object itself.
>
> The workaround that we found was to split the code into two methods:
>
>    @POST
>    @Path("/myResource/{c}/{d}")
>    @Consumes({"application/xml", "application/json"})
>    public E getE(A a, @PathParam("") B b);
>
>    @POST
>    @Path("/myResource/{c}/{d}")
>    @Consumes({"application/x-www-form-urlencoded"})
>    public E getEForm(@FormParam("") A a, @PathParam("") B b);
>
> I'm also not certain if this is a bug.
>
> Thanks,
> Josh
>
>
> On Mon, Apr 12, 2010 at 11:39 AM, Jungwoo Jang <jungwoo3687@hotmail.com
> >wrote:
>
> >
> > Hello all,
> >
> > I apologize in advance if this is the incorrect mailing list to post this
> > question to.
> >
> > I have a question around whether some behavior I am seeing is a bug or if
> > it is functioning as designed.
> >
> > I am trying out the parameter bean example in the cxf jaxrs
> documentation.
> >  Note the following has been simplified, since I am only worried about
> > @FormParam types.
> > @Path("/customer/{id}")
> > public class CustomerService {
> >
> >    @POST
> >    public Response addCustomerOrder(@FormParam("") OrderBean bean) {
> >        ...
> >    }
> > }
> >
> > public class OrderBean {
> >   public void setId(Long id) {...}
> >   public void setWeight(int w) {...}
> > }
> >
> > So, this works when I use a browser as the client.
> > But when I use the client runtime library it does not.
> >
> >    CustomerService service = JAXRSClientFactory.create(...);
> >    service.addCustomerOrder(new OrderBean(123, 150));
> >
> > After debugging through the code, it seems like the
> >
> rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java's
> > handleForm(...) method is doing something it shouldn't be doing.
> >
> >    FormUtils.addPropertyToForm(form, p.getName(),
> > params[p.getIndex()].toString());
> >
> > The params[p.getIndex()] is the OrderBean that I have passed in.  But
> then
> > this code converts it to a String and then in the
> > FormUtils.addPropertyToForm method, it makes an
> > InjectionUtils.extractValuesFromBean(value, "") call, where the value is
> the
> > toString() value of the OrderBean.
> >
> > So, the http request has bytes=somebytes, when I was expecting id=123 and
> > weight=150.
> >
> > Here is the jira ticket that I believe was why this code was introduced.
>  https://issuesowever,
> > .
> apache.org/jira/browse/CXF-2389?page=com.atlassian.jira.plugin.ext.subversion%3Asubversion-commits-tabpanel
> <
> https://issues.apache.org/jira/browse/CXF-2389?page=com.atlassian.jira.plugin.ext.subversion%3Asubversion-commits-tabpanel
> >
> >
> > So, is this bug?  I did a search for jira tickets to see if this was
> > already a known issue. If it is a bug, should I file a new jira ticket
> and
> > link it to the ticket mentioned above?
> >
> > Thanks,
> > Jungwoo
> >
> >
> > _________________________________________________________________
> > The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with
> > Hotmail.
> >
> >
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
> >
>
>
>
> --
> Josh Cummings
> The Pi-Dye T-Shirt Shop
> http://www.pidye.com
> 801-556-2751
>
> Learn how to be a part of the biggest redistribution of pi in the history
> of
> mankind at www.pidye.com
>

Re: Question about ClientProxyImpl

Posted by Josh Cummings <jo...@gmail.com>.
For what it is worth, we experienced the same thing.

We originally had only one method:

    @POST
    @Path("/myResource/{c}/{d}")
    @Consumes({"application/x-www-form-urlencoded"})
    public E getE(@FormParam("") A a, @PathParam("") B b);

We had client Java code and form posts using the one method.  Upon upgrading
to 2.2.7, it appears that the handleForm method gets the String name of our
object instead of the object itself.

The workaround that we found was to split the code into two methods:

    @POST
    @Path("/myResource/{c}/{d}")
    @Consumes({"application/xml", "application/json"})
    public E getE(A a, @PathParam("") B b);

    @POST
    @Path("/myResource/{c}/{d}")
    @Consumes({"application/x-www-form-urlencoded"})
    public E getEForm(@FormParam("") A a, @PathParam("") B b);

I'm also not certain if this is a bug.

Thanks,
Josh


On Mon, Apr 12, 2010 at 11:39 AM, Jungwoo Jang <ju...@hotmail.com>wrote:

>
> Hello all,
>
> I apologize in advance if this is the incorrect mailing list to post this
> question to.
>
> I have a question around whether some behavior I am seeing is a bug or if
> it is functioning as designed.
>
> I am trying out the parameter bean example in the cxf jaxrs documentation.
>  Note the following has been simplified, since I am only worried about
> @FormParam types.
> @Path("/customer/{id}")
> public class CustomerService {
>
>    @POST
>    public Response addCustomerOrder(@FormParam("") OrderBean bean) {
>        ...
>    }
> }
>
> public class OrderBean {
>   public void setId(Long id) {...}
>   public void setWeight(int w) {...}
> }
>
> So, this works when I use a browser as the client.
> But when I use the client runtime library it does not.
>
>    CustomerService service = JAXRSClientFactory.create(...);
>    service.addCustomerOrder(new OrderBean(123, 150));
>
> After debugging through the code, it seems like the
> rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java's
> handleForm(...) method is doing something it shouldn't be doing.
>
>    FormUtils.addPropertyToForm(form, p.getName(),
> params[p.getIndex()].toString());
>
> The params[p.getIndex()] is the OrderBean that I have passed in.  But then
> this code converts it to a String and then in the
> FormUtils.addPropertyToForm method, it makes an
> InjectionUtils.extractValuesFromBean(value, "") call, where the value is the
> toString() value of the OrderBean.
>
> So, the http request has bytes=somebytes, when I was expecting id=123 and
> weight=150.
>
> Here is the jira ticket that I believe was why this code was introduced.  https://issuesowever,
> .apache.org/jira/browse/CXF-2389?page=com.atlassian.jira.plugin.ext.subversion%3Asubversion-commits-tabpanel<https://issues.apache.org/jira/browse/CXF-2389?page=com.atlassian.jira.plugin.ext.subversion%3Asubversion-commits-tabpanel>
>
> So, is this bug?  I did a search for jira tickets to see if this was
> already a known issue. If it is a bug, should I file a new jira ticket and
> link it to the ticket mentioned above?
>
> Thanks,
> Jungwoo
>
>
> _________________________________________________________________
> The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with
> Hotmail.
>
> http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
>



-- 
Josh Cummings
The Pi-Dye T-Shirt Shop
http://www.pidye.com
801-556-2751

Learn how to be a part of the biggest redistribution of pi in the history of
mankind at www.pidye.com