eclipse Java WS仅在tcp/ip监视器打开时响应
创建了一个非常基本的WS。我有LoggingHandler、Test、TestImpl和;TestPublisher。我的发布者在下面创建我的端点:
import javax.xml.ws.Endpoint;
public class TestPublisher {
public static void main(String[] args) {
LoggingHandler handle = new LoggingHandler();
Endpoint ep = Endpoint.publish( "http://localhost:8060/message/hello",
new TestImpl() );
ep.getBindings().getHandlerChain().add( new LoggingHandler() );
System.out.print( handle.toString() );
}
}
我的测试界面使用@WebService&@WebMethod,并且只执行“String getHello(String str);” 我的TestImpl实现了测试并使用@WebService(endpointInterface=“my package location”),并且只有一个方法“public String getHelloWorld(String str){return“Hello”+str;} 我的处理程序有handleMessage、handleFault和;关我可以把这个代码也,但我不认为这会有帮助
当我在同一台(dev)RH6 pc上访问localhost:port/message/hello时,它工作得非常好!我得到“你好,我的名字”。我甚至可以在localhost上获得一个wsdl文件:port/message/hello?wsdl
当我尝试从任何其他pc、linux或windows访问时,会出现超时或“无法显示网页”错误。因此,我在eclipse中的tcp/ip监视器中进行了设置,以便在不更改任何代码的情况下监视和路由从端口8061(新端口)到WS-port[here][link3]的流量
结果:除了运行该服务(dev)的电脑外,我仍然无法从任何其他电脑访问8060。因此,我将浏览器指向另一台pc上的端口8061(tcp/ip监视器),它成功地返回了我的消息!我是否需要运行监视器才能转发到java Web服务
在我的RH6机箱上,我没有运行防火墙或web服务器&;我在我的工作网络上。我可以在不使用tcp/ip监视器的情况下,成功地启动tomcat6并从另一台pc到达8080
# 1 楼答案
试试端点。使用计算机的ip地址发布
例:端点。发布(”http://192.168.0.1:8060/message/hello))