Hi Tam
> Thanks for that, I have now got it up and running. You also have to add the
> @XmlRootElement annotation to the object returned by the service otherwise
> you get a NullPointerException.
The exception is quite poor all-right at the moment. In this case and exception
saying no MessageBodyWriter was found has to be generated. I actually have a
minor patch I did on weekends to improve on some of the things in this area,
including the support for a standard WebApplicationException.
> > Is it possible to specify the @ProduceMime type in the Spring context file.
You can do
@GET
@ProduceMime("application/xml", "application/json")
and then, depending on the value of the Accept type the approproate
MessageBodyWriter will be selected. You can also debug the formats like this :
GET /yourResource?_contentType=application/xml
or
GET /yourResource?_contentType=xml
etc, with "xml" in this case defaulting to application/xml. More shortcuts like
'xml' can be easily added to a system query handler dealing with this query...
Cheers, Sergey
>
> Hi Sergey
>
> Thanks for that, I have now got it up and running. You also have to add the
> @XmlRootElement annotation to the object returned by the service otherwise
> you get a NullPointerException.
> Is it possible to specify the @ProduceMime type in the Spring context file.
> At the moment if i want a service to return different mime types it seems
> like i need multiple implementations of the method with different
> annotations.
>
> Cheers, Tam
>
>
> Sergey Beryozkin wrote:
>>
>> Hi Tam,
>>
>> I'm sorry, but I've never got to updating the documentaion but I've
>> created a JIRA to have the docs updated asap, I'll try to update
>> them in the next few days...
>> In meantime have a look please at a basic jaxrs demo, the only difference
>> with what the documentation says is that
>> different annotations are used, for ex @GET instead of @HttpMethod("Get"),
>> @Path instead of @UriTemplate and @PathParam instead of
>> @UriParam...
>>
>> Cheers, Sergey
>>
>> ----- Original Message -----
>> From: "tam.sayers" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Tuesday, March 25, 2008 11:05 AM
>> Subject: Re: re[jira] stful uri binding value not set to input parameter
>> bean property
>>
>>
>>>
>>> Hi Sergey
>>>
>>> Thanks for the reply. The version of the jax-rs implementation in the
>>> apache-cxf-2.1-incubator-20080321.032844-42.zip seems to be different
>>> than
>>> the one described in
>>> http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html.
>>> Do you know if there is any documentation anywhere for the newer version?
>>>
>>> Tam
>>>
>>>
>>> Sergey Beryozkin wrote:
>>>>
>>>> Hi
>>>>
>>>> Please try the same with the current JAX-RS implementation in CXF.
>>>> I'm not qute sure why this does not work for the CXF HTTP binding, but
>>>> one
>>>> thing is that
>>>> this binding can be considered depecated...unless someone can confirm
>>>> they're going to mantain it...
>>>>
>>>> Cheers, Sergey
>>>>
>>>>>
>>>>> I have tried calling the following service using the cxf 2.0.4 and 2.1
>>>>> code
>>>>> and when using both the accountNumber is not set to the GetForAccount
>>>>> bean.
>>>>> When debugging through the code I can see that
>>>>> the values are being read from the URL and an XML element is being
>>>>> generated
>>>>> in the form:
>>>>>
>>>>> <getTelephoneForAccount>
>>>>> <accountNumber>ab123</accountNumber>
>>>>> </getTelephoneForAccount>
>>>>>
>>>>> This is then added to the message but never gets set to the
>>>>> GetForAccount
>>>>> bean. Does anybody know why the property is not being set?
>>>>>
>>>>> Service definition:
>>>>>
>>>>> @WebService(targetNamespace = "http://uk.co.jdwilliams/account")
>>>>> public interface AccountTelephoneNumberService {
>>>>> @Get
>>>>> @HttpResource(location = "/telnos/{accountNumber}")
>>>>> @WebResult(name = "telephoneNo")
>>>>> TelephoneNumberTO getTelephoneForAccount(GetForAccount
>>>>> getForAccount);
>>>>> }
>>>>>
>>>>> input bean:
>>>>>
>>>>> public class GetForAccount {
>>>>> private String accountNumber;
>>>>>
>>>>> /**
>>>>> * @return the accountNumber
>>>>> */
>>>>> public String getAccountNumber() {
>>>>> return accountNumber;
>>>>> }
>>>>>
>>>>> /**
>>>>> * @param accountNumber the accountNumber to set
>>>>> */
>>>>> public void setAccountNumber(String accountNumber) {
>>>>> this.accountNumber = accountNumber;
>>>>> }
>>>>> }
>>>>>
>>>>> Spring bean definition:
>>>>>
>>>>> <jaxws:endpoint id="accountTelNoService"
>>>>> implementor="#accountTelephoneNumberService"
>>>>> address="/xml/account"
>>>>> bindingUri="http://apache.org/cxf/binding/http">
>>>>> <jaxws:serviceFactory>
>>>>> <bean
>>>>> class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
>>>>> <property name="wrapped" value="false" />
>>>>> </bean>
>>>>> </jaxws:serviceFactory>
>>>>> </jaxws:endpoint>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/restful-uri-binding-value-not-set-to-input-parameter-bean-property-tp16183429p16183429.html
>>>>> Sent from the cxf-issues mailing list archive at Nabble.com.
>>>>
>>>> ----------------------------
>>>> IONA Technologies PLC (registered in Ireland)
>>>> Registered Number: 171387
>>>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
>>>> Ireland
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/restful-uri-binding-value-not-set-to-input-parameter-bean-property-tp16183429p16273694.html
>>> Sent from the cxf-issues mailing list archive at Nabble.com.
>>
>> ----------------------------
>> IONA Technologies PLC (registered in Ireland)
>> Registered Number: 171387
>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/restful-uri-binding-value-not-set-to-input-parameter-bean-property-tp16183429p16298037.html
> Sent from the cxf-issues mailing list archive at Nabble.com.
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland