Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Web service that sends excel file to client
    primarykey
    data
    text
    <p>Hi friends i am new to web services, their is requirement in my project that a webservice should be created which does some database interaction process and business logic than it has to send an excel file to the requested client [file should be downloaded on to client meachine].</p> <ol> <li><p><strong>I know we can send attachment in both SOAP and RESTFULL. i want to know which is the best method to send excel file and how to send it sample code so that i can get idea.</strong></p></li> <li><p><strong>I know web service communicate through xml i want to know that convert excel file to xml and send it to client from their client convert it again to excel is that method ok from both performance and efficient point of view.</strong> </p></li> </ol> <p>Finally i want to know which is the best method to achieve it and sample code so that i can work on it. </p> <p>Updated question This is my web service method in project A</p> <pre><code>@Path("/todo") public class TodoResource { @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response getfile(){ File file =new File("D:\\Test.xls"); // Initialize this to the File path you want to serve. return Response.ok(file, MediaType.APPLICATION_OCTET_STREAM).build(); } } </code></pre> <p>This in project B where i created client</p> <pre><code> protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;Starting of Project Test Call &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"); ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource(getBaseURI()); //Get Excel Download System.out.println(":::::: The Application APPLICATION_OCTET_STREAM Response :::::: "); System.out.println(service.path("rest").path("todo").accept(MediaType.APPLICATION_OCTET_STREAM).get(String.class)); System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;Ending of Project Test Call &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"); } private static URI getBaseURI() { return UriBuilder.fromUri("http://localhost:8080/WebService_XML").build(); } </code></pre> <p>my requirement is the client will send some info like parameter 1,parameter 2 etc. based on that it will interact with database and a file will be created. and that file should be send to client.like on click call webservice process it send that file to client, browser download popup window will appear to save or open should appear. on click save save it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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