我在 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);
您可以使用 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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)