3

我是 java web 服务的初学者。

我创建了一个简单的 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;
    }
}
4

1 回答 1

4

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

  wsgen -keep -cp  package.HelloWeb
于 2013-07-21T06:50:41.070 回答