【问题标题】:There are no Operations specified in WSDLWSDL 中没有指定操作
【发布时间】:2014-12-30 19:33:02
【问题描述】:

我正在研究网络服务。 我做了一个例子,我使用了 Eclipse、MySql、Apache TomCat 8 和 Axis2。 这个项目包含一个简单的 WebService,它连接到一个名为“users”的表以创建一个 CRUD 流程。 问题是当我使用 userDAO 类创建 web 服务时,因为这些方法没有出现在服务列表中。 出现:

UserDAO

Service Description : Please Type your service description here

Service EPR : http://localhost:8080/ExemploWS/services/UsuarioDAO

Service Status : Active


There are no Operations specified

发生了什么事?

用户类:

import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.sql.PreparedStatement;


public class UserDAO {

    public boolean insertUser(User user){

        try {
            Connection conn =  ConectaMySql.obtemConexao();
            String queryInsert = "INSERT INTO USER VALUES (null,?,?)";
            PreparedStatement ppStm = conn.prepareStatement(queryInsert);
            ppStm.setString(1, user.getName());
            ppStm.setInt(2, user.getAge());
            ppStm.executeUpdate();
            conn.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return false;
        }

        return true;
    }

    public boolean updateUser(User user){

        try {
            Connection conn =  ConectaMySql.obtemConexao();
            String queryInsert = "UPDATE USUARIO SET name = ?, age = ?, WHERE id = ?)";
            PreparedStatement ppStm = conn.prepareStatement(queryInsert);
            ppStm.setString(1, user.getName());
            ppStm.setInt(2, user.getAge());
            ppStm.setInt(3, user.getId());
            ppStm.executeUpdate();
            conn.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return false;
        }

        return true;
    }   

    public boolean deleteUser(User user){
        try {
            Connection conn =  ConectaMySql.obtemConexao();
            String queryInsert = "DELETE FROM USUARIO WHERE id=?";
            PreparedStatement ppStm = conn.prepareStatement(queryInsert);
            ppStm.setInt(1, user.getId());
            ppStm.executeUpdate();
            conn.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return false;
        }

        return true;
    }
    public ArrayList<User> searchAllUsers(){

        ArrayList<User> list = new ArrayList<User>();

        try {
            Connection conn =  ConectaMySql.obtemConexao();
            String queryInsert = "SELECT * FROM user";
            PreparedStatement ppStm = conn.prepareStatement(queryInsert);
            ResultSet rSet = ppStm.executeQuery();
            while(rSet.next()){
                User usr = new User();
                usr.setId(rSet.getInt(1));
                usr.setName(rSet.getString(2));
                usr.setAge(rSet.getInt(3));
                list.add(usr);
            }
            conn.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return list;
    }

    public User searchUserById(int id) {
        User usr = null;
        try {
            Connection conn =  ConectaMySql.obtemConexao();
            String queryInsert = "SELECT * FROM user WHERE id=?";
            PreparedStatement ppStm = conn.prepareStatement(queryInsert);
            ppStm.setInt(1, id);
            ResultSet rSet = ppStm.executeQuery();
            if(rSet.next()){
                usr = new User();
                usr.setId(rSet.getInt(1));
                usr.setName(rSet.getString(2));
                usr.setAge(rSet.getInt(3));

            }else{
                return usr;
            }
            conn.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return usr;

    }

    public boolean deleteUser(int id){

        return deleteUser(new User(id,"",0));
    }
}

【问题讨论】:

    标签: java mysql eclipse web-services tomcat


    【解决方案1】:

    所以,为了解决这个问题,我有时不得不重新启动 eclipse。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多