从远程计算机使用 Web 服务

发布于 2024-12-12 18:26:52 字数 611 浏览 2 评论 0原文

我有一个使用 jdk 6 构建的桌面应用程序,它发布可供 Web 应用程序使用的 Web 服务。到目前为止,当两个应用程序在同一台物理计算机上运行时,我没有遇到任何问题,我可以毫无问题地访问 wsdl,并且 Web 应用程序与桌面应用程序配合得很好。问题是我无法从同一网络中的远程计算机访问服务。两台PC已连接并且可以交互。如果我在 PC1 中运行这两个应用程序,我可以从 PC2 使用 web 应用程序,通过

http://PC1:8080

我当前发布的方式如下:

public Publicador(){
 servicios= new Servicios();
Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);
}

其中 PC1 是电脑的名称。从 PC1 上,我可以从以下地址看到生成的 wsdl,它是我用于 wsimport 命令的:

http://PC1:8686/servicios?wsdl

但我无法从 PC2 上看到。

为什么从 PC1 外部看不到它,有什么想法吗?

I have a desktop application built with jdk 6 which publishes web services to be consumed by a web application. So far I've had no problem while both applications are running in the same physical computer, i can access the wsdl without any problem and the web application works with the desktop application just fine. The thing is I cannot access to the services from a remote computer in the same network. The two PCs are connected and can interact. If I run both applications in PC1, from PC2 I can use the webapp through

http://PC1:8080

I am currently publishing like this:

public Publicador(){
 servicios= new Servicios();
Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);
}

where PC1 is the name of the pc. From PC1, i can see the generated wsdl from the following address, and it's the one I used for the wsimport command:

http://PC1:8686/servicios?wsdl

But I cannnot from PC2.

Any ideas why it is not visible from outside PC1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何止钟意 2024-12-19 18:26:52

尽管看起来令人难以置信,但我找到了最简单的答案......而不是像

Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);

我发布的

Endpoint endpoint = Endpoint.publish("http://0.0.0.0:8686/servicios", servicios);

那样发布并解决了它......

另一个解决方案是从文件中获取要发布的地址,这也有效。我不知道为什么它没有硬编码......我最终这样做了:

Properties prop = new Properties();
InputStream is = null;
String currenDir = System.getProperty("user.dir");
String nombreArchivo = currenDir + File.separator + "ubicacion.PROPERTIES";
try {
is=new FileInputStream(nombreArchivo);
prop.load(is);
} catch(IOException ioe) {}

String pc = prop.getProperty("ServiciosWeb");      
Endpoint endpoint = Endpoint.publish( pc, servicios);
}

Incredible as it may seem, I found the simplest of answers... Instead of publishing as

Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);

I published as

Endpoint endpoint = Endpoint.publish("http://0.0.0.0:8686/servicios", servicios);

and that solved it...

Another solution was to get the address to publish from a file, that worked too. I don't know why it didn't hardcoded... I ended up doing it like this:

Properties prop = new Properties();
InputStream is = null;
String currenDir = System.getProperty("user.dir");
String nombreArchivo = currenDir + File.separator + "ubicacion.PROPERTIES";
try {
is=new FileInputStream(nombreArchivo);
prop.load(is);
} catch(IOException ioe) {}

String pc = prop.getProperty("ServiciosWeb");      
Endpoint endpoint = Endpoint.publish( pc, servicios);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文