画像をエンコードして wcf に送信する機能を作成しました。ええと、クエリ文字列パラメーターを使用していません。URL を使用してパラメーターを渡します。これは私の Android コードであり、これは正常に動作します。
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 実装でも正常に動作します。そのため、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 ビット文字列をパラメーターとして安全に渡す方法は? 私はそれについてあまり経験がありません。誰かが私に提案を与えることができれば、私は感謝します.