【发布时间】:2012-03-16 03:35:45
【问题描述】:
我正在尝试在 Eclipse 中创建一个简单的 Web 服务。首先我创建了一个空的java项目,并在src文件夹中添加了以下三个文件
- Greeting.java
package com.alfaisaliah;
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService
public interface Greeting {
@WebMethod
String sayHello(String name);
}
- GreetingImp.java
package com.alfaisaliah;
import javax.jws.WebService;
@WebService(endpointInterface="com.alfaisaliah.Greeting")
public class GreetingImp implements Greeting {
@Override
public String sayHello(String name) {
return "Hello " + name;
}
}
- WSPublisher
package com.alfaisaliah;
import javax.xml.ws.Endpoint;
public class WSPublisher {
public static void main(String[] args){
Endpoint.publish("http://localhost:8081/WS/Greeting", new GreetingImp());
}
}
我正在关注的教程没有指定任何服务器来运行 Web 服务!我想知道是否需要指定任何服务器。我已经有 Tomcat v5.5,但在这个例子中没有使用它。每当我将此项目作为 java 项目运行时,我都会遇到某种错误。谁能帮我确定我的问题是在哪里尝试运行 Web 服务。这是eclipse控制台的输出
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class com.alfaisaliah.jaxws.SayHello
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class com.alfaisaliah.jaxws.SayHelloResponse
当我再次运行该项目时,它说该地址已在使用中
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class com.alfaisaliah.jaxws.SayHello
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class com.alfaisaliah.jaxws.SayHelloResponse
Exception in thread "main" com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Address already in use
感谢你们的帮助:)
【问题讨论】:
-
关于创建 wrapper beans 的消息是 OK 的。它基本上是 JAX-WS 动态生成 WSDL 能力的一部分。
标签: java eclipse web-services jax-ws