1

'daki getResponseCode ile ilgili bir sorum var, bu bağlantı doğru çalışıyor. Ama bir Mjpeg (jpeg-stream) Kameraya bağlandığımda "System.out.println (" onreturn oncesi " + httpConnection.getResponseCode()); Çıkış Konsolunda. Emulator ve MDS kullanıyorum. MDS'de gösterebilirim, ... akış geliyor.jpeg Kameraya bağlanmayı denediğimde httpConnection ve BlackBerry

url = getUrl(); 
queryString = encodeURL(queryString);  
byte postmsg[] = queryString.getBytes("UTF-8"); 
httpConnection = (HttpConnection) Connector.open(url 
+ ";deviceside=false", Connector.READ_WRITE); 
httpConnection.setRequestMethod(HttpConnection.GET); 
httpConnection.setRequestProperty("Authorization", getBase64Encode()); 
os = httpConnection.openDataOutputStream(); 

for (int i = 0; i < postmsg.length; i++) { 
os.write(postmsg[i]); 
} 
{ 
if (!cancel) { 
    System.out.println(httpConnection.getURL()+ 
     " *****"+httpConnection.getPort()); 
    System.out.println("onreturn oncesi" 
     + httpConnection.getResponseCode()); 
    onReturn(httpConnection.getResponseCode(), httpConnection 
     .openInputStream(),(int) httpConnection.getLength()); 

    System.out.println("onreturn sornrası"); 
} 
os.close(); 
httpConnection.close(); 
} 
} catch (Exception e) { 
System.out.println("hata " + e.getMessage()); 
try { 
    httpConnection.close(); 
    Thread.sleep(60); 
} catch (Exception ie) { 
} 
onError(e); 
} 

cevap

1

Sorunlarınız, üstbilgilerinizi doğru şekilde ayarlamamanızdır.

Gönderim verileriniz httpConnection.setRequestMethod(HttpConnection.GET);httpConnection.setRequestMethod(HttpConnection.POST); olmalıdır.

Ve ayrıca içerik Uzunluğu belirlesin: httpConnection.setRequestProperty("Content-Length", Integer.toString(postmsg.length));

Ve devam edip bu kuracak ona iken:

içerik türü: belki olarak "image/jpeg ". o httpConnection.setRequestProperty("Content-Type", "image/jpeg");

UserAgent Ben bir örümcek düşünerek, bazı siteler RIM (Java/xxx) varsayılan user-agent bloke bulduk, bu yüzden ayarlamak ister ... MJPEG için olması gerektiği konusunda emin değilim kullanıcı aracısı. httpConnection.setRequestProperty("User-Agent", "MyCoolApp/V1 (App_RIM)");

JDE'nin hangi sürümünü kullanıyorsunuz? Bu HTTPS üzerinden mi? Soruyorum çünkü 4.5 gibi eski sürümlerde http ve https farklı şekilde oluşturmalısınız. Daha yeni sürümlerde, muhtemelen Bağlayıcı yerine yeni ConnectionFactory kullanmalısınız.

İyi Şanslar ve Umarım bunu anlamayasınız !!!

+0

4.6 kullanıyorum ... ConnectionFactory 4.6 çalışmıyor ve bende bir HTTPS bağlantısına sahip olmanızdan emin olmanız gerekir ... – atasoyh

+0

@atasoyh Bağlayıcıyı doğru Bağlama sınıfına çevirdiğinizden emin olun. Kullanım Yetkiniz olduğundan bu yana bağlantınız HTTPS üzerinden mi? Eğer öyleyse, (HttpsConnection) 'a (HttpConnection) dönüştürmeyin. Ayrıca, Google'da "Marcus Watkins ve ConnectionFactory" için arama yapın (4.6 için geçerli), onun kaymakam değil ama sizi doğru yönde yönlendirecek. – eSniff

İlgili konular