Results 1 to 3 of 3
  1. #1
    gedas is offline Member
    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    0

    Default web service problems

    hey,
    i have a method on a web service that supose to store few details in to a text file. simple

    here is the method.

    Java Code:
        @WebMethod(operationName = "addEmployee")
        @Oneway
        public void addEmployee(@WebParam(name = "name")
        String name, @WebParam(name = "surname")
        String surname, @WebParam(name = "login")
        String login, @WebParam(name = "password")
        String password) {
            try
                {
                    BufferedWriter bufewr;
                    bufewr = new BufferedWriter(new FileWriter("src/java/emp/employee.txt"));
                    for (int i=0; i<1; i++){
                       bufewr.write(name+" ");
                        bufewr.write(surname);
                        bufewr.newLine();
                        bufewr.write(login);
                        bufewr.newLine();
                        bufewr.write(password);
                        bufewr.newLine();
    
    
                    }
    
                 bufewr.flush();
                 bufewr.close();
                }
                catch(IOException evt)
                {
                    System.err.println("Exception: " + evt.getMessage());
                    System.exit(1);
                }
    
        }

    however when i execute the method on the client side with something like this

    Java Code:
       private void addEmpButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
            if(nameField.getText().isEmpty() || surnameField.getText().isEmpty() ||
                     loginField.getText().isEmpty() || passwordField.getText().isEmpty()){
                       JOptionPane.showMessageDialog(this,
                        "some fields maybe empty",
                        "Inane warning",
                        JOptionPane.WARNING_MESSAGE);
                   }
                   else{
    
                       if(port.condition(loginField.getText()))
                       {
                               JOptionPane.showMessageDialog(this,
                               "same login id has been entered",
                               "Inane warning",
                               JOptionPane.WARNING_MESSAGE);
                       }
                       else{
                           port.addEmployee(nameField.getText(), surnameField.getText(),
                                     loginField.getText(), passwordField.getText());
    }
    the problem is that the data does not get stored. i am using glassfish v3.1 server and and i am using netbeans ide.

    server gives me this error message
    XML Code:
    SEVERE: Exception: employee.txt (The system cannot find the file specified)
    Completed shutdown of Log manager service
    also i am getting this exception in the terminal
    XML Code:
    Exception in thread "AWT-EventQueue-0" com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
    	at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:121)
    	at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:142)
    	at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
    	at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
    	at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
    	at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
    	at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
    	at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
    	at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
    	at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124).....

    well i understand that the server cannot find the file that i provide but why not i believe if i execute "addEmployee" method it should create a file automatically ...
    i am very confused....

    any help will be appreciated


    THANK YOU

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    Java Code:
                catch(IOException evt)
                {
                    System.err.println("Exception: " + evt.getMessage());
                    System.exit(1);
                }
    First off, use printStackTrace() for the exception, since otherwise you lose the stack trace information.
    Also, why are you shutting down the web service on an exception, which is why I expect you're getting the connection refused at the client?
    Return an error of some sort.

    Where exactly are you expecting this file to be created?
    Does that directory structure exist?

  3. #3
    gedas is offline Member
    Join Date
    Feb 2010
    Posts
    51
    Rep Power
    0

    Default

    thanks i solved it
    everything is working thanks a lot for the help
    Last edited by gedas; 06-28-2011 at 09:56 PM.

Similar Threads

  1. web service
    By wama in forum NetBeans
    Replies: 0
    Last Post: 03-17-2011, 11:05 PM
  2. InputStream/Jar Problems/File IO Problems
    By rdjava in forum Advanced Java
    Replies: 31
    Last Post: 01-17-2011, 11:12 AM
  3. Web service + sql
    By barbiess in forum NetBeans
    Replies: 3
    Last Post: 11-09-2010, 08:59 AM
  4. how to call service method inside another service
    By kirtichopra2003 in forum Web Frameworks
    Replies: 1
    Last Post: 10-24-2009, 02:19 AM
  5. Web Service from JSP
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-02-2007, 05:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •