내가 구현 한 REST 서비스에서 REST 서비스로 데이터를 전송합니다이미지를 업로드하기 위해 C#으로 자바
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "add/{idAlbum}/{name}/image")]
void Add(string idAlbum, string name, Stream image);
나는 C#을 클라이언트와 함께 사용 성공 : 그래서 지금
byte[] image = lireFichier(@"C:\Users\user\Pictures\asap2.jpeg");
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "image/jpeg");
var results = client.UploadData("http://localhost:1767/ImageService.svc/add/1/REST/image", "PUT", image);
I 이런 (작동하지 않는) 자바 클라이언트 (안드로이드)와 함께 사용하려는 :
HttpURLConnection conn = (HttpURLConnection) new URL("http://localhost:1767/ImageService.svc/add/1/RESTjava/image").openConnection();
conn.setRequestMethod("PUT");
conn.setDoOutput(true);
conn.connect();
OutputStream out = conn.getOutputStream();
Bitmap img = ((BitmapDrawable)getResources().getDrawable(R.drawable.entourage)).getBitmap();
ByteArrayOutputStream bao = new ByteArrayOutputStream();
img.compress(Bitmap.CompressFormat.JPEG, 90, bao);
byte[] data = bao.toByteArray();
out.write(data);
나는 어떤 오류가 발생하지 않지만 이것은 없습니다. 예외 없음.
06-05 14:11:57.736: I/ASAP PICS(746): onPreExecute
06-05 14:11:57.745: I/ASAP PICS(746): doInBackground
06-05 14:11:57.816: I/System.out(746): 405
06-05 14:44:26.245: D/dalvikvm(971): GC freed 238 objects/332400 bytes in 34ms
06-05 14:11:57.905: I/ASAP PICS(746): onPostExecute
예외? 리턴 코드? – Fildor
예외 없음 .06-05 14 : 11 : 57.736 : I/ASAP PICS (746) : onPreExecute 06-05 14 : 11 : 57.745 : I/ASAP PICS (746) : doInBackground 06-05 14 : 11 : 57.816 : I/System.out (746) : 405 06-05 14 : 11 : 57.905 : I/ASAP PICS (746) : onPostExecute – Nahani