LAN 中的主机未解析
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 JCIFS 库让 Java 解析 NetBIOS 名称。您可以从 http://jcifs.samba.org/ 获取它。将其添加到您的项目中,然后使用类似的代码将主机名转换为 IP 地址。
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.
很可能
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.