使用 Apt 的 Java Web 服务。我需要注释处理器吗?怎么了?
我一直在尝试制作一个简单的网络服务,并一直在关注 本教程 。不幸的是我被困住了。这是我到目前为止所做的:
1)我创建了这个类:
package server;
import javax.jws.WebService;
@WebService
public class HelloImpl {
/**
* @param name
* @return Say hello to the person.
*/
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
2)我运行了:
apt HelloImpl.java
3)我收到此警告:
hostName[username:~/Desktop/webtest][534]% apt HelloImpl.java
warning: Annotation types without processors: [javax.xml.bind.annotation.XmlRootElement, javax.xml.bind.annotation.XmlAccessorType, javax.xml.bind.annotation.XmlType, javax.xml.bind.annotation.XmlElement]
1 warning
apt 命令应该(根据教程)生成这些文件:
HelloServiceImpl.wsdl
schema1.xsd
classes/server/HelloImpl.class
classes/server/jaxrpc/SayHello.class
classes/server/jaxrpc/SayHelloResponse.class
classes/server/jaxrpc/SayHello.java
classes/server/jaxrpc/SayHelloResponse.java
这是我调用时生成的文件apt:(
HelloImpl.java (not generated but it is still in the directory)
HelloImpl.class
server/jaxws/SayHello.cass
server/jaxws/SayHell.java
server/jaxws/SayHelloResponse.class
server/jaxws/SayHelloResponse.java
缺少:)
HelloServiceImpl.wsdl
schema1.xsd
(路径也略有不同)
我怀疑正在生成警告并且未生成其他文件,因为我有“没有处理器的注释类型:”。
我认为该警告表明它需要一个注释工厂(处理器)。我知道您可以通过以下方式指定工厂:
在此处输入代码
-cp 指定在哪里查找用户类文件和注释处理器工厂
我只是不确定要指定哪个工厂。 (或者也许我需要进行不同的配置)。
I have been trying to make a simple web service and have been following this tutorial . Unfortunately I am stuck. Here is what I have done so far:
1) I created this class:
package server;
import javax.jws.WebService;
@WebService
public class HelloImpl {
/**
* @param name
* @return Say hello to the person.
*/
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
2) I ran:
apt HelloImpl.java
3) I get this warning:
hostName[username:~/Desktop/webtest][534]% apt HelloImpl.java
warning: Annotation types without processors: [javax.xml.bind.annotation.XmlRootElement, javax.xml.bind.annotation.XmlAccessorType, javax.xml.bind.annotation.XmlType, javax.xml.bind.annotation.XmlElement]
1 warning
The apt command should (according to the tutorial) produce these files:
HelloServiceImpl.wsdl
schema1.xsd
classes/server/HelloImpl.class
classes/server/jaxrpc/SayHello.class
classes/server/jaxrpc/SayHelloResponse.class
classes/server/jaxrpc/SayHello.java
classes/server/jaxrpc/SayHelloResponse.java
This is what was generated when I called apt:
HelloImpl.java (not generated but it is still in the directory)
HelloImpl.class
server/jaxws/SayHello.cass
server/jaxws/SayHell.java
server/jaxws/SayHelloResponse.class
server/jaxws/SayHelloResponse.java
(missing:)
HelloServiceImpl.wsdl
schema1.xsd
(the paths are also slightly different)
I suspect that the warning is being generated and the other files are not being generated because I have "Annotation types without processors:".
I think that the warning indicates that it needs an annotation factory (processor). I know that you can specify what a factory by:
enter code here
-cp Specify where to find user class files and annotation processor factories
I am just unsure of what factory to specify. (Or maybe I need to configure something differently).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那个 5 年前的教程可能有点过时了。 jax-ws 是 jax-rpc 的后继者。不过,也许您所需要的只是运行 wsgen 工具而不是合适。
请查看此处的迷你教程 进程内 SOAP 服务服务器对于Java
That 5 year old tutorial might be a bit out of date. jax-ws is the successor to jax-rpc. Though, maybe all you need is to run the wsgen tool instead of apt.
Take a look here for a mini tutorial In-process SOAP service server for Java