【发布时间】:2010-09-09 21:07:26
【问题描述】:
我构建了一个最小的 Web 服务并使用 javax.xml.ws.Endpoint 发布它。
如果我尝试在
http://localhost:1234/AddService?wsdl 工作正常。
尝试通过http://192.168.0.133:1234/AddService?wsdl 接收它,我没有收到任何东西。
这个地址和localhost一样。
是否可以在不提供地址的情况下发布网络服务?
package test;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class AddService {
@WebMethod
public int add(int a, int b){
return a+b;
}
public static void main(String[] args ){
Endpoint.publish("http://localhost:1234/AddService", new AddService());
}
}
把代码改成
Endpoint.publish("http://192.168.0.133:1234/AddService", new AddService());
在 IP 地址上获取 wsdl,但在 localhost 上没有。
难道不能只定义端口吗?
【问题讨论】:
标签: java web-services jax-ws endpoint