Hi Sergey,

I just noticed that in the user's guide. My apologies with that. Just a follow-up though, is it possible to be able to receive an XML representation of Account in invoking AccountService.get(), while having that sub-resource locator feature? In removing the @GET in AccountService.get(), I am no longer able to invoke the said method.

Again, my thanks!

Gabo

Sergey Beryozkin wrote:
Hi

you have @GET on AccountService.get() so it's not seen as a subresource locator method.
if you push @GET down to the Account.getAccountID then it will work...

Cheers, Sergey



Hi All,

I have the following resources:

//the service class:

@ConsumeMime("text/xml")
@ProduceMime("text/xml")
public class AccountService{
   @GET
   @Path("/Account/{uniqueId}")
   public Account get(
           @PathParam("uniqueId")
           long uniqueId
           ) {
       //do something here and return the Account object
   }
}

//the account class
@XmlType(name="Account")
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement(name="Account")
public class Account {
   private String accountID = ""

   @Path("accountID")
   public String getAccountID() {
       return accountID;
   }

   public void setAccountID(String accountID) {
       this.accountID = accountID;
   }
}

beans.xml having the following configuration for the service instance:

   <jaxrs:server id="accountRestService" address="/rest/Accounts">
       <jaxrs:serviceBeans>
           <ref bean="AccountService" />
       </jaxrs:serviceBeans>
   </jaxrs:server>

Now, accessing the method that returns an Account object works fine, i.e. access to http://localhost:8080/rest/Accounts/Account/1 responds with the xml representation of the Account object.

However, I was hoping to take advantage of Sub-resource locators as mentioned in http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html . When I try accessing http://localhost:8080/rest/Accounts/Account/1/accountID , I end up getting a 'No operation matching request'. I'm thinking this might be caused by the fact that the said method does not take any parameters? or that I have JAX-WS annotations at class level for the Account class?

Gabo Manuel
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.8.2/1740 - Release Date: 10/22/2008 7:24 PM

Reply via email to