开发者

Java Web service using Apt. Do I need an annotation processor? What is wrong?

开发者 https://www.devze.com 2022-12-17 16:30 出处:网络
I have been trying to make a simple web service and have been followingthis tutorial . Unfortunately I am stuck.Here is what I have done so far:

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.ja开发者_运维技巧va
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).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消