【问题标题】:Invalid chacter issue in webservice url in androidandroid中Web服务URL中的无效字符问题
【发布时间】:2012-09-12 12:05:39
【问题描述】:

我无法在 android 应用程序中调用以下 Web 服务。 http://seba:pl,%5Dd77@www.bjadi.com/administrator/components/com_ivmstore/ivmwebservices/vmcategory.php

我的 logcat 出现以下错误 -

java.io.FileNotFoundException: http://seba:pl,%5Dd77@www.bjadi.com/administrator/components/com_ivmstore/ivmwebservices/ivmsettings.php 09-12 17:32:16.098: W/System.err(1575): 在 org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:1162)

请确保我在 url 中传递用户名/密码。

谁能指导我如何实现它?

【问题讨论】:

标签: android web-services malformedurlexception


【解决方案1】:

您需要将您的登录名/密码放在标题中(这不好,因为有一些方法可以做到这一点,但它很好,因为它可以防止先发制人的登录问题),例如:

String header = "Basic " + Base64.encodeToString(("login" + ":" + "password").getBytes(), Base64.NO_WRAP);
urlConnection.setRequestProperty("Autorization", header);

或者,您可以使用凭据提供程序,我不记得它是如何工作的

编辑

当然应该是“授权”。 hwrdprkns 发布的链接包含执行此操作的所有方法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-23
    相关资源
    最近更新 更多