在java中创建非常简单的Web服务时运行时建模器错误

时间:2013-07-21 06:14:24

标签: java web-services jax-ws

我是java网络服务的初学者。

我创建了一个简单的Web服务,并在尝试发布时如下

 Endpoint.publish("http://localhost:8080/HelloWeb", new HelloWeb());

获取如下错误

Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.ravi.jaxws.SayGreeting is not found. Have you run APT to generate them?
at com.sun.xml.internal.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:256)
at com.sun.xml.internal.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:567)
at com.sun.xml.internal.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:514)
at com.sun.xml.internal.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:341)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:227)
at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:308)
at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:174)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:420)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:439)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:208)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:138)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:90)
at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
at com.ravi.Server.main(Server.java:9)

任何想法都在这里出错。

我的webservice类非常简单,这里是代码:

    @WebService
@SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL)
public class HelloWeb {

    @WebMethod
    public String sayHello(String name){
        return "Hello "+name;
    }
}

1 个答案:

答案 0 :(得分:3)

首先调用wsgen实用程序。该实用程序生成各种工件,即Endpoint.publish方法生成服务的WSDL所需的java类型。这是示例 在工作目录中运行

  wsgen -keep -cp  package.HelloWeb