LAN 中的主机未解析

发布于 2024-09-08 07:25:28 字数 616 浏览 9 评论 0原文

我在 HttpPost 上收到 IOExeption“主机未解析”。在本例中,端点是我的 LAN 上具有 Web 服务的计算机。 (http://pc259:8080/test/service.asmx)。我的 LAN 使用 WIFI。 Android 知道解析计算机名吗?

StringEntity se = new StringEntity(xmlDataToSend);
se.setContentType("text/xml");
HttpPost httppost = new HttpPost(endPoint);     
httppost.setHeader("Content-Type","application/soap+xml");
httppost.setEntity(se);         
HttpClient httpclient = new DefaultHttpClient();
Log.i(TAG, " - Before execute");
httpResponse = (BasicHttpResponse) httpclient.execute(httppost);

Im getting a IOExeption 'Host is unresolved' on HttpPost. The Endpoint in this case a a computer on my LAN with a webservice. (http://pc259:8080/test/service.asmx). Im using WIFI to my LAN. Does Android know to to resolved computernames?

StringEntity se = new StringEntity(xmlDataToSend);
se.setContentType("text/xml");
HttpPost httppost = new HttpPost(endPoint);     
httppost.setHeader("Content-Type","application/soap+xml");
httppost.setEntity(se);         
HttpClient httpclient = new DefaultHttpClient();
Log.i(TAG, " - Before execute");
httpResponse = (BasicHttpResponse) httpclient.execute(httppost);

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

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

发布评论

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

评论(2

风吹雪碎 2024-09-15 07:25:28

您可以使用 JCIFS 库让 Java 解析 NetBIOS 名称。您可以从 http://jcifs.samba.org/ 获取它。将其添加到您的项目中,然后使用类似的代码将主机名转换为 IP 地址。

import jcifs.netbios.NbtAddress;
...
NbtAddress nbtAddress = NbtAddress.getByName(hostname);
InetAddress address = nbtAddress.getInetAddress();
String ipAddress = address.getHostAddress();

You can get Java to resolve NetBIOS names by using the JCIFS library. You can get it from http://jcifs.samba.org/. Add that to your project and then use code like this to convert a host name to an IP address.

import jcifs.netbios.NbtAddress;
...
NbtAddress nbtAddress = NbtAddress.getByName(hostname);
InetAddress address = nbtAddress.getInetAddress();
String ipAddress = address.getHostAddress();
究竟谁懂我的在乎 2024-09-15 07:25:28

很可能 pc259 未在您的 DNS 服务器中定义,而是 NetBios 主机名(请参阅 http://en.wikipedia.org/wiki/NetBIOS#NetBIOS_name_vs_host_name)。
我认为 Android 无法解析此类主机名 - 您需要将此计算机添加到 DNS 存储库。

Most likely pc259 is not defined in you DNS server, but is a NetBios hostname (see http://en.wikipedia.org/wiki/NetBIOS#NetBIOS_name_vs_host_name).
I don't think Android can resolve these kind of hostnames - you'll need to add this computer to the DNS repository.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文