使用注释在 JBoss AS 7 中创建 Web 服务
我有一个包含嵌套 EJB 项目的 EAR 文件、一个 .war 动态 Web 项目和一个包含实体 bean 定义的 .jar 文件。
我正在尝试使用此远程接口创建一个简单的基于 SOAP 的 Web 服务:
package session;
import javax.ejb.Remote;
import javax.jws.WebMethod;
import javax.jws.WebService;
@Remote
@WebService
public interface HelloWorldRemote {
@WebMethod
public String greet(String from);
@WebMethod
public String getMessage();
}
和此实现类:
package session;
import javax.ejb.Stateless;
import javax.jws.WebService;
@Stateless
@WebService(endpointInterface = "session.HelloWorldRemote", serviceName = "HelloWorldWS")
public class HelloWorldImpl implements HelloWorldRemote {
public String greet(String from) {
return "Hello, " + from + ".";
}
public String getMessage() {
return "It's working.";
}
}
但是,当我部署 EAR 文件时,日志没有提及任何类、WSDL、Web 服务或任何可能导致我相信它正在尝试根据我的注释创建网络服务。
我缺少什么?
I have an EAR file with a nested EJB project, a .war dynamic web project, and a .jar file containing entity bean definitions.
I'm trying to make a simple SOAP-based web service using this remote interface:
package session;
import javax.ejb.Remote;
import javax.jws.WebMethod;
import javax.jws.WebService;
@Remote
@WebService
public interface HelloWorldRemote {
@WebMethod
public String greet(String from);
@WebMethod
public String getMessage();
}
and this implementation class:
package session;
import javax.ejb.Stateless;
import javax.jws.WebService;
@Stateless
@WebService(endpointInterface = "session.HelloWorldRemote", serviceName = "HelloWorldWS")
public class HelloWorldImpl implements HelloWorldRemote {
public String greet(String from) {
return "Hello, " + from + ".";
}
public String getMessage() {
return "It's working.";
}
}
However, when I deploy the EAR file, the log makes no mention of either class, WSDL, webservices, or anything that would lead me to believe that it's making an attempt to create the webservice based on my annotations.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这花了太长时间才发现,而且我很偶然地发现了它。我发现一个论坛解释说我需要使用“--server-config=standalone-preview.xml”标志来启用对某些 JBoss 功能的支持。在尝试找出在哪里可以找到/获取standalone-preview.xml之后,我发现我一直在使用错误版本的JBoss。
与直觉相反,JBoss 7 的“Web”配置文件不支持Web 服务。 (至少不是 JAX-WS 品种的那些。)
解决方案是下载“Everything”配置文件,然后使用上面的标志。如果您像我一样在 Eclipse 中工作,则可以通过双击底部“服务器”选项卡中的服务器,然后单击“打开启动配置”来添加该标志。
我希望我为其他人节省了与我追踪此问题所花费的时间一样多的时间。
This took far too long to discover and I came across it quite by accident. I found a forum explaining that I needed to use the " --server-config=standalone-preview.xml" flag to enable support for certain pieces of JBoss functionality. After trying to find out where standalone-preview.xml could be found/acquired, I learned that I've been using the wrong version of JBoss.
Counter-intuitively, the "Web" profile of JBoss 7 does not support Web services. (At least not those of the JAX-WS variety.)
The solution was to download the "Everything" profile and then use the above flag. If you're working in Eclipse as I was, you may add the flag by double-clicking on your server in the "servers" tab at the bottom, then hitting "Open Launch Configuration".
I hope I saved someone else as many hours as I spent tracking this down.
您是否已在 war 的
web.xml
中注册了您的 Web 服务?Have you registered your web service in the war's
web.xml
?