Note that there are some explanatory texts on larger screens.

plurals
  1. POerror in compiling code that call to rest service
    text
    copied!<p>I trying to use this example and learn how to call to rest service, when I put this code I getting error since the eclipse doesn't know the <strong>org.example.Customer;</strong> .the error in definition Customer customer. how can I import it to my project ? I have tried to use the eclipse suggestion without success. (fix project setup etc)</p> <pre><code>import java.util.List; import javax.ws.rs.core.MediaType; import org.example.Customer; import com.sun.jersey.api.client.*; public class JerseyClient { public static void main(String[] args) { Client client = Client.create(); WebResource resource = client.resource("http://localhost:8080/CustomerService/rest/customers"); // Get response as String String string = resource.path("1") .accept(MediaType.APPLICATION_XML) .get(String.class); System.out.println(string); // Get response as Customer Customer customer = resource.path("1") ------"*Here is the error in customer*------- .accept(MediaType.APPLICATION_XML) .get(Customer.class); System.out.println(customer.getLastName() + ", "+ customer.getFirstName()); // Get response as List&lt;Customer&gt; List&lt;Customer&gt; customers = resource.path("findCustomersByCity/Any%20Town") .accept(MediaType.APPLICATION_XML) .get(new GenericType&lt;List&lt;Customer&gt;&gt;(){}); System.out.println(customers.size()); } } </code></pre> <p>I have used the code from this blog</p> <p><a href="http://blog.bdoughan.com/2010/08/creating-restful-web-service-part-55.html" rel="nofollow">http://blog.bdoughan.com/2010/08/creating-restful-web-service-part-55.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload