0

创建了一个非常基本的 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 实现了 Test 并使用了 @WebService(endpointInterface="my package location") 并且只有一个方法 "public String getHelloWorld(String str){ return "Hello" + str; } 我的处理程序有 handleMessage、handleFault 和 close。我也可以把这段代码放上去,但我认为这不会有帮助。

当我在同一台(开发)RH6 电脑上访问 localhost:port/message/hello 时,效果很好!我得到“你好我的名字”。我什至可以在 localhost:port/message/hello?wsdl 获得一个 wsdl 文件

当我尝试从任何其他 PC、Linux 或 Windows 访问时,我收到超时或“无法显示网页”错误。所以我在 Eclipse 中设置了 tcp/ip 监视器来监视和路由从端口 8061(新端口)到我的 WS 端口 [here][link3] 的流量,而无需更改任何代码。

结果:我仍然无法从任何其他电脑访问 8060,除了运行服务(开发)的电脑。所以我将我的浏览器指向另一台电脑的端口 8061(tcp/ip 监视器),它成功返回了我的消息!我需要运行监视器来转发到我的 java web 服务吗?

在我的 RH6 机器上,我没有运行防火墙或 Web 服务器,我在我的工作网络上。我可以在不使用 tcp/ip 监视器的情况下成功启动 tomcat6 并从其他 pc 进入 8080。

4

1 回答 1

1

使用您机器的 IP 地址尝试 Endpoint.publish,

例如:Endpoint.publish("http://192.168.0.1:8060/message/hello")

于 2012-05-30T20:16:43.000 回答