Results 1 to 3 of 3
Thread: web service problems
- 06-28-2011, 03:04 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 51
- Rep Power
- 0
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
the problem is that the data does not get stored. i am using glassfish v3.1 server and and i am using netbeans ide.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()); }
server gives me this error message
also i am getting this exception in the terminalXML Code:SEVERE: Exception: employee.txt (The system cannot find the file specified) Completed shutdown of Log manager service
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
- 06-28-2011, 03:20 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
First off, use printStackTrace() for the exception, since otherwise you lose the stack trace information.Java Code:catch(IOException evt) { System.err.println("Exception: " + evt.getMessage()); System.exit(1); }
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?
- 06-28-2011, 09:40 PM #3
Member
- Join Date
- Feb 2010
- Posts
- 51
- Rep Power
- 0
Similar Threads
-
web service
By wama in forum NetBeansReplies: 0Last Post: 03-17-2011, 11:05 PM -
InputStream/Jar Problems/File IO Problems
By rdjava in forum Advanced JavaReplies: 31Last Post: 01-17-2011, 11:12 AM -
Web service + sql
By barbiess in forum NetBeansReplies: 3Last Post: 11-09-2010, 08:59 AM -
how to call service method inside another service
By kirtichopra2003 in forum Web FrameworksReplies: 1Last Post: 10-24-2009, 02:19 AM -
Web Service from JSP
By Eric in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 07-02-2007, 05:00 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks