我是 java 网络服务的初学者。
我创建了一个简单的网络服务,并尝试按如下方式发布它
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
@SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL)
public class HelloWeb {
@WebMethod
public String sayHello(String name){
return "Hello "+name;
}
}
最佳答案
首先调用 wsgen 实用程序。此实用程序生成各种工件,即方法 Endpoint.publish 生成服务的 WSDL 所需的 java 类型。这是示例 在工作目录运行
wsgen -keep -cp package.HelloWeb
关于java - 在 Java 中创建非常简单的 Web 服务时出现运行时建模器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17769629/