如何将base 64编码字符串从android发送到wcf

如何将base 64编码字符串从android发送到wcf,android,wcf,Android,Wcf,我编写了对图像进行编码并将其发送到wcf的功能。Um未使用查询字符串参数。Um使用URL传递参数。这是我的安卓代码,很好用 public JSONUpdate(String jobNumber, String documentType, String documentFilePath, String DocumentFileName, String encodedImage, String url) { this.url = url + jobNumbe

我编写了对图像进行编码并将其发送到wcf的功能。Um未使用查询字符串参数。Um使用URL传递参数。这是我的安卓代码,很好用

public JSONUpdate(String jobNumber, String documentType,
        String documentFilePath, String DocumentFileName,
        String encodedImage, String url) {

    this.url = url + jobNumber.trim() + "/" + documentType.trim() + "/"
            + documentFilePath.trim().replace("/", "___") + "/"
            + DocumentFileName.trim() + "/" + encodedImage;
}



 public boolean updateService() {
    boolean result = false;
    HttpClient httpClient = new DefaultHttpClient();
    try {
        HttpPost httpPost = new HttpPost(this.url);
        try {
            HttpResponse httpResponse = httpClient.execute(httpPost);
            if (httpResponse != null) {
                if (httpResponse.getStatusLine().getStatusCode() == 200)
                    result = true;
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (Exception ex) {
        String p = ex.getLocalizedMessage();
        String y = ex.getMessage();
    }
    if (!result) {

    }
    return result;
}
在我的WCF实现中,它也可以正常工作,除非每次我包含encoded string参数时,它都会抛出一个错误,因为encoded string包含“+”和“\”。所以URL被破坏了。这是我的服务WCF代码

    [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,
    UriTemplate = "attachment/{jobNumber}/{documentType}/{documentFilePath}/{DocumentFileName}/{encodedImage}",
    BodyStyle = WebMessageBodyStyle.Bare)]
    public bool InsertAttachment(String jobNumber, String documentType,
        String documentFilePath, String documentFileName,
         String encodedImage = null)
    {
        //implementation was written
    }
如何使用+和\将编码的64位字符串作为参数安全地传递?我在这方面没有多少经验。如果有人能给我一个建议,我将不胜感激

试试自API 8以来就可以使用的Android实现

Base64.encodeToString(youtString.getBytes(...), Base64.NO_WRAP + Base64.URL_SAFE);

你的目标安卓版本是什么?安卓3.0是我的安卓版本我们可以将其应用到图像中吗?当然,只要图像是在字节数组中。但为什么我会出现内存不足异常?当把它放到http post中时?可能图像太大,无法在内存中编码?您应该注意,编码比普通图像占用的内存多30-40%。很可能:)无论如何,谢谢