| | |
Java and Web Services
![]() |
I know I should probably post this in Web Services of Web Development, but this may be beneficial to others that are trying to lean something about it too.
I'm getting lot of strange behaviour from this assignment that at this point I'm willing to throw it away and never work on it.
I have class that run various queries with database. With use of Axis2 plug-in I was able to generate WSDL (This has some red sections which I'm not able to work out). Here is small section of two methods out of it to demonstrate some errors I'm getting
I was able to use this WSDL to create client side and get automated files Service, ServiceLocator, _PortType, SoapBindingStub.
To communicate with service I use following code
However for example when I'm trying to log in through logEmployee(String usr, String pass) method server side receive only user name string and password is lost. (I found solution to this in sending these strings in array)
Secondly when I tried to retrieve list of all employees through viewEmployees() method that is supposed to return ArrayList<Employee> I'm getting warning or error that found return is actually Object[].
Can somebody shed some light into this darkness?
I'm getting lot of strange behaviour from this assignment that at this point I'm willing to throw it away and never work on it.
I have class that run various queries with database. With use of Axis2 plug-in I was able to generate WSDL (This has some red sections which I'm not able to work out). Here is small section of two methods out of it to demonstrate some errors I'm getting
Java Syntax (Toggle Plain Text)
public Employee logEmployee(String usr, String pass) { System.out.println("Username = "+ usr+" Password = "+pass); Employee e = new Employee(); Connection conn = cm.getConnection(); if (conn != null) { ResultSet rs = null; PreparedStatement preparedStatement = null; try { String strQuery = "SELECT employee_id, branch_id, password, firstName, lastName " + "FROM employee WHERE employee_id=? AND password=?"; preparedStatement = conn.prepareStatement(strQuery); preparedStatement.setString(1, usr); preparedStatement.setString(2, pass); rs = preparedStatement.executeQuery(); while (rs.next()) { e.setEmployeeID(rs.getString("employee_id")); e.setBranchID(rs.getString("branch_id")); e.setPassword(rs.getString("password")); e.setFirstName(rs.getString("firstName")); e.setLastName(rs.getString("lastName")); } } catch (SQLException ex) { ex.printStackTrace(); } finally { try { rs.close(); preparedStatement.close(); } catch (SQLException sqle) { sqle.printStackTrace(); } catch (NullPointerException npe) { npe.printStackTrace(); } cm.putConnection(conn); } } return e; } public ArrayList<Employee> viewEmployees() { ArrayList<Employee> employee = new ArrayList<Employee>(); Connection conn = cm.getConnection(); if (conn != null) { ResultSet rs = null; PreparedStatement preparedStatement = null; Employee emp; try { String strQuery = "SELECT employee_id, branch_id, firstName, lastName " + "FROM employee ORDER BY lastName,firstName"; preparedStatement = conn.prepareStatement(strQuery); rs = preparedStatement.executeQuery(); while (rs.next()) { emp = new Employee(); emp.setEmployeeID(rs.getString("employee_id")); emp.setBranchID(rs.getString("branch_id")); emp.setFirstName(rs.getString("firstName")); emp.setLastName(rs.getString("lastName")); employee.add(emp); } } catch (SQLException ex) { ex.printStackTrace(); } finally { try { rs.close(); preparedStatement.close(); } catch (SQLException sqle) { sqle.printStackTrace(); } catch (NullPointerException npe) { npe.printStackTrace(); } cm.putConnection(conn); } } return employee; }
I was able to use this WSDL to create client side and get automated files Service, ServiceLocator, _PortType, SoapBindingStub.
To communicate with service I use following code
Java Syntax (Toggle Plain Text)
try{ EmployeeQueriesServiceLocator locator = new EmployeeQueriesServiceLocator(); EmployeeQueries_PortType service = locator.getEmployeeQueries(); //execution of any service method here } catch(ServiceException ex){ ex.printStackTrace(); } catch(RemoteException re){ re.printStackTrace(); }
Secondly when I tried to retrieve list of all employees through viewEmployees() method that is supposed to return ArrayList<Employee> I'm getting warning or error that found return is actually Object[].
Can somebody shed some light into this darkness?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
first issue sounds really strange, the system out doesn't print pass?
with the second, are you importing Employee?
with the second, are you importing Employee?
Yes of course I do import Employee
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
A piece of advice: use a debugger, given that we have no way of reproducing the scenario and the code posted so far looks OK.
BTW, why are you catching a
BTW, why are you catching a
NullPointerException ? Catching unchecked exceptions without any kind of processing is *always* a bad practice and screams of a pre-condition check. Instead put null checks before closing the database resources [like result sets and statements]. Java Syntax (Toggle Plain Text)
Connection conn = null; Statement stmt = null; try { try { // do something } finally { if(stmt != null) stmt.close(); if(conn != null) conn.close(); } } catch(Exception e) { e.printStackTrace(); }
I don't accept change; I don't deserve to live.
Yeah NullPointerException is one of many small things I need to battle through as many of the things I pick up either from IDE suggestions (which is not always best to do) or following other people code and often miss the reason of the use. Hopefully with all this technical reading I'm doing I will loose some bad habits
Right now I'm "cracking" through Service-Oriented Architecture with Java Web Services by Mark Hansen and found nice quote
This assignment is already submitted, it is only my stubbornness that push now to find out why it did not worked in first place and in doing so learn something new and maybe help somebody in the future with insufficient resources and support from tutor/teacher
Right now I'm "cracking" through Service-Oriented Architecture with Java Web Services by Mark Hansen and found nice quote
•
•
•
•
Unfortunately, if you are like me, you may have found the Java Web Services learning curve a little steep. It seems that lots of powerful and complex machinery is required just to deploy a Java class as a Web service or create a simple client to consume such services. Sure, you can get the simple "Hello World" application from the Java EE 5 tutorial to work. However, when you need to deploy your purchase ordering system, things suddenly seem to get much more complicated. Either the WSDL you start with gets compiled into myriad bizarre classes that have to be manually wrapped and mapped into your real purchasing system, or, if you start from your Java classes, the WSDL that gets produced doesn't turn out the way you need it to. If you have been frustrated by problems like these, I sympathize with you.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- How to get WSDL from web services created using SOAPpy (Python)
- Require Java Spring and Hibernate developers (Web Development Job Offers)
- Senior Web Solutions Developer (ColdFusion, Javascript, mySQL, HTML, CSS & XML Tools) (Web Development Job Offers)
- java to c# (C#)
- Open Source (LAMP) Software Engineers for Hot Web 2.0 Company -San Francisco (Web Development Job Offers)
- Google API in Web Services Application (Java)
- Senior Software Engineer (Java) (Web Development Job Offers)
- web services using REST (Java)
- Myhomehost.com | Online Web Services (Web Hosting Deals)
- Survey of Web Technologies (IT Professionals' Lounge)
Other Threads in the Java Forum
- Previous Thread: help!
- Next Thread: Quick Search(Finding Duplicate Records)
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows






