Hi,
I have a simple RESTful Web Service that I got from one
of the samples on the web. I am able to invoke it from browser and it
shows the output on the browser, but when I try and call it from my
client code using WebClient, it's throwing the following exception, Am I
missing something ?
WARNING: .No operation matching request path /customers is found,
ContentType : */*, Accept :
text/html,application/xhtml+xml,application/xml,.
Jul 29, 2009 10:38:23 AM
org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available
Jul 29, 2009 10:38:23 AM
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
Here is the Client code :
WebClient wc =
WebClient.create("http://localhost:8080/cxf-webservices/webservices/cust
omerservice");
wc.accept("text/html,application/xhtml+xml,application/xml");
Response getresponse = wc.path("/customers").get();
Here is the Web Service :
<jaxrs:server id="customerService" address="/">
<jaxrs:serviceBeans>
<ref bean="customerservice"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="customerservice" class="test.CustomerService" />
@Path("/customerservice/")
@Produces("text/xml")
public class CustomerService {
private TreeMap<Integer, Customer> customerMap = new
TreeMap<Integer, Customer>();
public CustomerService() {
//Hard coded for testing
Customer customer = new Customer();
customer.setId(0);
customer.setName("Harold Abernathy");
customer.setAddress("Sheffield, UK");
addCustomer(customer);
}
@GET
@Path("/customers")
public CustomerCollection getCustomers() {
return new CustomerCollection( customerMap.values());
}
@GET
@Path("/customers/{id}")
public Customer getCustomer(@PathParam("id") int cId) {
return customerMap.get(cId);
}
@POST
@Path("/customers/add")
@Produces("text/plain")
@Consumes("application/xml")
public String addCustomer(Customer customer) {
int id = customerMap.size();
customer.setId(id);
customerMap.put(id, customer);
return "Customer " + customer.getName() + " added with Id " +
id;
}
Any help will be appreciated.
Thanks
Kiran
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Notice: This information is intended only for the person(s) or entity(ies) to
which it is addressed. This information may contain information that is
confidential or otherwise protected from disclosure. If you are not the
intended recipient of this message, or if this message has been addressed to
you in error, please immediately alert the sender by reply e-mail and then
delete this message, including any attachments. Any dissemination, distribution
or other use of the contents of this message by anyone other than the intended
recipient is strictly prohibited.