Hi , i am new to Jersey in calling Rest Api
I created a New Blog Bean project in NetBeans and added the Jersey libraries as
package blogbean;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import java.awt.PageAttributes.MediaType;
import java.util.List;
import javax.ws.rs.core.MediaType;
public class BlogBean {
// Create a client config
ClientConfig config = new DefaultClientConfig();
// Create a client using the ClientConfig just created
Client client = Client.create(config);
// Create a WebResource and point the WebResource to the Base URI of localhost.
WebResource webResource = client.resource("http://localhost:3000");
//Get Authentication Key which is a Base 64 encoding of username and password
String userName="aruna";
String password="aruna";
String authentication = "Basic " + Base64Coder.encodeString(userName + ":"+ password);
public static void main(String[] args) {
// TODO code application logic here
}
public List<BlogBean> getBlogsXml() {
return webResource.path("http://localhost:3000/api/blogs.xml").header("Authorization", authentication)
.accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<List<BlogBean>>() {});
}
}
Above code is working now ? But i am not able to see the xml file generated . How to get the xml ??