Hi
I think the reason no match is found is that CustomerService uses a global
@Produces("text/xml")
values which applies to all resource methods unless specifically overridden,
while WebClient says it can accept
text/html,application/xhtml+xml,application/xml
so you might want to update either a WebClient accept call or @Produces to
also include text/xml
I'll update the server code which reports the problem to make sure a more
specific message is reported. You should also get a 406 response code in
this case (per the spec). Give it a try please.
cheers, Sergey
kiran.sidhu wrote:
>
> 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 ?
>
> Hi
>
>
>
> 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.
>
>
--
View this message in context:
http://www.nabble.com/Running-into-problems-with-using-WebClient-tp24724574p24725928.html
Sent from the cxf-user mailing list archive at Nabble.com.