【问题标题】:configuring a java bean as a web service将 Java bean 配置为 Web 服务
【发布时间】:2015-12-27 23:12:10
【问题描述】:

我收到此错误:

IWAB0398E 从 Java 生成 WSDL 时出错:尝试写入重复的模式元素:{http://service.fussa.com}更新

IWAB0398E 从 Java 生成 WSDL 时出错:尝试写入重复的模式元素:{http://service.fussa.com}更新 轴故障 故障代码:{http://xml.apache.org/axis/}Server.generalException 故障子代码: faultString:尝试写入重复的架构元素:{http://service.fussa.com}更新 故障演员: 故障节点: 故障详情: {http://xml.apache.org/axis/}stackTrace:尝试写入重复的架构元素:{http://service.fussa.com}更新

我的班级:

public class SmartphoneService implements IDao<Smartphone> {

private static final String JPQL_SELECT_PAR_ID = "SELECT u FROM Smartphone u WHERE u.idSmartphone=:id";

// Injection du manager, qui s'occupe de la connexion avec la BDD

private EntityManagerFactory emf;
private EntityManager em;

public SmartphoneService() {
    emf = Persistence.createEntityManagerFactory("manager1");
    em = emf.createEntityManager();
}

// Enregistrement d'un nouvelle smartphone

public boolean create( Smartphone smart) {
    try {
        em.getTransaction().begin();
        em.persist(smart);
        em.getTransaction().commit();
        return true;

    } catch (Exception e) {
        if (em.getTransaction() != null) {
            em.getTransaction().rollback();
        }
    } finally {
        em.close();
        emf.close();
    }
    return false;
}

// Recherche d'une smartphone à partir de son id

public Smartphone findById(int id) {
    Smartphone smart = null;
    try {
        smart = em.find(Smartphone.class, id);
        return smart;
    } catch (Exception e) {
        if (em.getTransaction() != null) {
            em.getTransaction().rollback();
        }
    } finally {
        em.close();
        emf.close();
    }
    return smart;
}

// MAJ d'une smartphone

public boolean update(Smartphone smart) {
    try {
        em.merge(smart);
        em.getTransaction().commit();
        return true;
    } catch (Exception e) {
        if (em.getTransaction() != null) {
            em.getTransaction().rollback();
        }
    } finally {
        em.close();
        emf.close();
    }
    return false;
}

// supprimer une smartphone

public boolean delete(Smartphone smart) {
    try {
        Smartphone smartphone = findById(smart.getIdSmartphone());
        if (smartphone != null) {
            em.remove(smartphone);
            em.getTransaction().commit();
            return true;
        }
    } catch (Exception e) {
        if (em.getTransaction() != null) {
            em.getTransaction().rollback();
        }
    } finally {
        em.close();
        emf.close();
    }
    return false;
}

// findALL

public List<Smartphone> findAll() {
    List<Smartphone> smarts = null;
    try {
        Query query = em.createQuery("SELECT e FROM Smartphone e");
        smarts = (List<Smartphone>) query.getResultList();
        return smarts;
    } catch (Exception e) {
        if (em.getTransaction() != null) {
            em.getTransaction().rollback();
        }
    } finally {
        em.close();
        emf.close();
    }
    return smarts;
}

// Recherche d'un utilisateur à partir de son id

public Smartphone findById2(int id) {
    Smartphone smart = null;
    Query requete = em.createQuery(JPQL_SELECT_PAR_ID);
    requete.setParameter("id", id);
    try {
        smart = (Smartphone) requete.getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
    return smart;
}

}

感谢您的帮助

【问题讨论】:

    标签: java eclipse web-services wsdl axis


    【解决方案1】:

    这个视频帮助我解决了我的问题: Building SOAP Web Service in Java Using Eclipse

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多