cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wiz...@yahoo.com
Subject Re: jaxrs:client configuration throws error
Date Thu, 06 Mar 2014 21:36:33 GMT
oh so sorry i clicked reply on the wrong thread.. i'm so sorry for hi-jacking the other thread..
please ignore my previous message.. i'm sorry ... i clicked the wrong thread when replying.


________________________________
 From: "wizpar@yahoo.com" <wizpar@yahoo.com>
To: "users@cxf.apache.org" <users@cxf.apache.org> 
Sent: Thursday, March 6, 2014 1:34 PM
Subject: Re: jaxrs:client configuration throws error
 


Sergey,

The only situtation where it's not working for is if we have a @BeanParam
it does not pass the annotations of the method related to that param
down to ParamConvertProvider 

public class MyBean {

private String field1;
private String field2;

public String getField1() {
return field1;
}

@PathParam("field1")
@Encoded
public void setField1(String field1) {
this.field1 = field1;
}

public String getField2() {
return field2;
}

@PathParam("field1")
public void setField2(String field2) {
this.field2 = field2;
}
}

@Path("/server")
public interface Server {
@GET
@Path("/{field1}/{field2}")
public BookBean book(@BeanParam MyBean myBean);
}

i think on clientside we can just send PathParam.class as anotations for these guys since
we know in this method we are dealing with pathparam be it from service bean or be it from
@BeanParam
ClientProxyImpl.getPathParamValues()


        for (String varName : methodVars) {
            Parameter p = paramsMap.remove(varName);
            if (p != null) {
                list.add(convertParamValue(params[p.getIndex()], getParamAnnotations(m,
p)));
            } else if (beanParamValues.containsKey(varName)) {
                list.add(convertParamValue(beanParamValues.get(varName), null));
            }
        }

if it's from beanParamValues 
we can just do convertParamValue(beanParamValues.get(varName), new Annotation[] {PathParam.class});

or get m.getDeclaredAnnotations() since these are declared and not part of 
parameter formal definition itself in method signature.

Now on server side we are only sending m.getParameterAnnotations()[0]
and again since for BeanParam the annotations are delcaredAnnotations
then we have to do some sort of check and choose between m.getParameterAnnotations() or m.getDeclaredAnnotations()
for BeanParams

inside JAXRSUtils.injectParameters()

                o = createHttpParameterValue(p, 
                                                m.getParameterTypes()[0],
                                                m.getGenericParameterTypes()[0],
                                                m.getParameterAnnotations()[0],
                                                message,
                                                values,
                                                ori);

please take a look as i believe this will fix the only param type so far that's not consistent
with other params.

i tested with @PathParam, @QueryParam, @MatrixParam, @FormParam
in service layer and they all work fine with param converters
but @BeanParam is the only one that leaves out sending annotations of it's related method
to converter.

thanks,
parwiz




________________________________
 From: Sergey Beryozkin <sberyozkin@gmail.com>
To: users@cxf.apache.org 
Sent: Wednesday, March 5, 2014 12:44 PM
Subject: Re: jaxrs:client configuration throws error
 

You need to add a cxf-rt-rs-client module as described in the docs

Sergey


On 05/03/14 19:25, Sonam Samdupkhangsar wrote:
> After reading the link I tried several combinations of the namespace in the  beans element
such as following but can't find the right way :
>
> <beans default-autowire="byName"
>     xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>     xmlns:jaxrs-client="http://cxf.apache.org/jaxrs-client"
>     xmlns:context="http://www.springframework.org/schema/context"
>     xmlns:util="http://www.springframework.org/schema/util"
>     xsi:schemaLocation="http://www.springframework.org/schema/beans
>          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>         http://www.springframework.org/schema/context
>         http://www.springframework.org/schema/context/spring-context-3.0.xsd
>         http://www.springframework.org/schema/util
>         http://www.springframework.org/schema/util/spring-util-3.0.xsd
>          http://cxf.apache.org/jaxrs
>          http://cxf.apache.org/jaxrs-client
>          http://cxf.apache.org/schemas/jaxrs.xsd
>          http://cxf.apache.org/jaxrs-client/schemas/jaxrs-client.xsd">
>
>
> -Sonam
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Wednesday, March 05, 2014 10:44 AM
> To: users@cxf.apache.org
> Subject: Re: jaxrs:client configuration throws error
>
> This is a migration issue:
>
> http://cxf.apache.org/docs/jax-rs.html#JAX-RS-FromCXF2.7.xtoCXF3.0.0
> (with the link to all of CXF changes from there)
>
> Sergey
>
> On 05/03/14 17:36, Sonam Samdupkhangsar wrote:
>> Hi,
>>
>> I am not able to get my jaxrs:client configuration to work using CXF version 3 milestone
2 . The following is my configuration:
>>
>> <?xml version="1.0" encoding="UTF-8"?> <beans
>> default-autowire="byName"
>>          xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>         
 xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:context="http://www.springframework.org/schema/context"
>>          xmlns:util="http://www.springframework.org/schema/util"
>>          xsi:schemaLocation="http://www.springframework.org/schema/beans
>>          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>>         
       http://www.springframework.org/schema/context
>>                http://www.springframework.org/schema/context/spring-context-3.0.xsd
>>                http://www.springframework.org/schema/util
>>                http://www.springframework.org/schema/util/spring-util-3.0.xsd
>>          http://cxf.apache.org/jaxrs
>>          http://cxf.apache.org/schemas/jaxrs.xsd">
>>
>>                   <jaxrs:client id="myClient" address="local://books"
>>                                   serviceClass="org.company.MyInterface"
>>                                   inheritHeaders="true">
>>                                   <jaxrs:headers>
>>                                                   <entry
key="userId" value="${dev.userId}"/>
>>                                                   <entry
key="password" value="${dev.password}"/>
>>                                   </jaxrs:headers>
>>                   </jaxrs:client>
>>
>> </beans>
>>
>>
>> I am seeing the following error when running a
 integ test:
>>
>> Caused by: org.xml.sax.SAXParseException; lineNumber: 54; columnNumber: 25; cvc-complex-type.2.4.c:
The matching wildcard is strict, but no declaration can be found for element 'jaxrs:client'.
>>          at
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXP
>> arseException(Unknown Source)
>>
>>
>> Is the Jaxrs client configuration in a separate namespace?
>>
>> thanks
>> -Sonam
>>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message