如何在Web服务中使用EJB3
我在eclipse id中创建了一个EJB项目,该项目是从数据库中检索数据并将数据写入数据库。我使用 JPA 完成了数据库处理部分。现在我想将其转换为网络服务。我用谷歌搜索了两天,但每个指南都给我带来了很多问题。 一些教程说只需将@webservice、@webmethod注释添加到Stateless bean类中,但是即使没有部署,eclipse也会出错。请有人帮助我继续前进。
谢谢。 伊苏鲁
I created a EJB project in eclipse id, the project is to retrieve data from a database and write data to the database. I did that database handling part using JPA. Now I want to convert this to a web service. I googled for two days but every guide stuck me some where with lot of questions.
Some of the tutorials said just add @webservice, @webmethod annotations to the Stateless bean class, but then eclipse gives error even without deploying. Please someone help me to move forward.
Thank you.
Isuru
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需添加注释就足够了:
默认情况下,所有公共方法都暴露给Web服务。如果你想限制它,你必须将@Webmethod添加到所有应该公开的方法中。
除此之外,您应该告诉我们您遇到了哪些错误。
It is indeed enough to just add the annotation:
By default, all public methods are exposed to the web service. If you want to limit it, you have to add @Webmethod to all methods which should be exposed.
Besides that, you should tell us which errors you get.
对我来说 Eclipse 不会抱怨这一点:
请向我们展示您的代码。
For me Eclipse does not complain about this:
Please show us your code.
尝试下载 Eclipse for Java EE 并仅使用无状态会话 bean 创建新项目。看看注释是否有效,我猜它是 Eclipse 中的“java 构建路径”设置的问题。
Try to download Eclipse for Java EE and create new project just with a stateless session bean. See if the annotations work, I guess its a problem with your 'java build path' settings in eclipse.