0

jpeg Cameraを接続しようとすると、この接続は正しく機能します。しかし、Mjpeg(jpeg-stream)カメラに接続すると、「System.out.println( "onreturn oncesi" + httpConnection.getResponseCode());」を表示できません。出力コンソールで。私はエミュレーターとMDSを使用しています。MDSで表示できます...ストリームが来ています。

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);
}
4

1 に答える 1

1

1つの問題は、リクエストヘッダーを正しく設定していないことです。

あなたの投稿データは、そうであるべきではありませhttpConnection.setRequestMethod(HttpConnection.GET);httpConnection.setRequestMethod(HttpConnection.POST);

また、 content-Lengthも設定する必要があります:httpConnection.setRequestProperty("Content-Length", Integer.toString(postmsg.length));

そして、私たちがそれに取り組んでいる間、私は先に進んでこれらを設定します:

コンテンツタイプ:「image/jpeg」のように。mJpegの場合はどうあるべきかわからない... httpConnection.setRequestProperty("Content-Type", "image/jpeg");

UserAgent RIM(Java / xxx)のデフォルトのユーザーエージェントをスパイダーだと思ってブロックしているサイトがあるので、ユーザーエージェントを設定したいと思います。httpConnection.setRequestProperty("User-Agent", "MyCoolApp/V1 (App_RIM)");

使用しているJDEのバージョンは何ですか?これはHTTPS経由ですか?4.5のような古いバージョンでは、httpとhttpsを別々に作成する必要があったのでお願いします。新しいバージョンでは、Connectorの代わりに新しいConnectionFactoryを使用する必要があります。

幸運と私はあなたがそれを理解することを願っています!!!

于 2010-11-19T17:34:28.097 に答える