Hi,
I am getting a WebApplicationException when I try to
create a proxy using JAXRSClientFactory, I tried both create API and
fromClient API.
The WebClient API works fine.
Here is my Client code :
WebClient wc =
WebClient.create("http://localhost:8080/cxf-webservices/webservices/cust
omerservice/");
wc.accept("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0
.8");
wc.encoding("UTF-8");
wc.header("accept-charset",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7");
CustomerService proxy = JAXRSClientFactory.create(
"http://localhost:8080/cxf-webservices/webservices/customerservice/",Cus
tomerService.class);
List<Customer> ccoll = proxy.getCustomers();
Right at the create statement, I get the following exception :
javax.ws.rs.WebApplicationException
at
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(JAXR
SClientFactoryBean.java:149)
at
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create(JAXRSClientFac
toryBean.java:118)
at
org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory
.java:71)
at
org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory
.java:56)
at
org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory
.java:46)
at com.asipay.ws.client.Client.main(Client.java:82)
Here is my Service class :
@Path("/customerservice/")
public class CustomerService {
private Map<Integer, Customer> customerMap = new TreeMap<Integer,
Customer>();
public CustomerService() {
//Hard coded for testing
Customer customer = new Customer();
customer.setId(0);
customer.setName("Jane Doe");
customer.setAddress("123 Howe Ave, Los Angeles, CA");
addCustomer(customer);
}
@GET
@Path("/customers")
@Produces("application/xml")
//@Resource MessageContext jaxrsContext;
public List<Customer> getCustomers() {
//return new Customers(customerMap.values());
return new ArrayList<Customer>(customerMap.values());
}
@GET
@Path("/customers/{id}")
@Produces("text/xml")
public Customer getCustomer(@PathParam("id") int cId) {
return customerMap.get(cId);
}
@PUT
@Consumes("application/xml")
@Produces("text/plain")
@Path("/customers/update/{id}")
public String updateCustomer(@PathParam("id") Long id, Customer
customer) {
customerMap.put(id.intValue(), customer);
return "Customer " + customer.getName() + " updated. Id =
" + id;
}
@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;
}
@DELETE
@Path("/customers/delete/{id}")
@Produces("text/plain")
@Consumes("application/xml")
public String deleteCustomer(@PathParam("id") Integer id) {
Customer customer = customerMap.get(id);
customerMap.remove(id);
return "Customer " + customer.getName() + " removed with Id "
+ id;
}
Any idea if I am missing something ?
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.