Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

HTTP Post on UMTS stops  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there I modified the code from this thread to suit the needs of J2ME:




Modifications I made:

* Use javax.microedition.io.HttpConnection instead of URLConnection
* Use String.getBytes() as DataOutputStream.writeBytes(String s) is not available in MIDP
* Use FileConnection from JSR-75 FileConnection API

I use it like this:



While the code seems to work well with GPRS, I experienced problems with UMTS.
Here are my test results:

||Device||K850iW910W910||K850i||K850iW910
||Java Plattform||JP-8JP-8JP-8JP-8JP-8JP-8
||Dataservice||GPRSGPRSGPRSGPRS||UMTS||UMTS
||Carrier||O2-DEO2-DEVodafone-DEVodafone-DEVodafone-DEVodafone-DE
||Filesize (Byte)||1.428.0771.428.0771.428.0771.428.0771.428.0781.428.079
||Upload (Byte)||completecompletecompletecomplete184320 (113664)627712 (199680)

The problem of partial upload seems only to exist with larger Files (not sure where exactly the lower bound is).

I hope this was not too much information for a start, but I am currently quite desperate about this bug.
I could really use some help here. I will also provide you with the results of a test on Nokia S60 phones
and the results of SE on device debugging.

[ April 03, 2008: Message edited by: Tilman Bender ]
Sorry could not manage to get my results formatted any better.
[ April 03, 2008: Message edited by: Tilman Bender ]
 
Tilman Bender
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue was solved by a firmware upgrade
Must have been a problem with JP-8. Works as expected on JP-8.2 now.

DeviceK850iW910
FirmwareR1EA037R1EA033
Java PlattformJP-8.2JP-8.2
DataserviceUMTSUMTS
Carrier VodafoneVodafone
Filesize (Byte)1.428.0771.428.077
Upload (Byte)completecomplete

HTH
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
I am trying to do http post with multipart/related content type. I wrote the code but it always gives exception when binary data starts to be written. can you look at see what is wrong? Thanks

c = (HttpConnection)Connector.open(url);
appM.gprog[pos].setValue((int)(10));
String axml="<?xml version='1.0'?><entry xmlns='http://www.w3.org/2005/Atom' " +
"xmlns:media='http://search.yahoo.com/mrss/' xmlns:yt='http://gdata.youtube.com/schemas/2007'>" +
" <media:group> <media:title type='plain'>Bad Wedding Toast</media:title>" +
" <media escription type='plain'> I gave a bad toast at my friend's wedding." +
" </media escription> <media:category" +
" scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>People" +
" </media:category> <media:keywords>toast, wedding</media:keywords>" +
" </media:group></entry>";
// Set the request method and headers
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("Host", "uploads.gdata.youtube.com");
c.setRequestProperty("Authorization", "GoogleLogin auth="+appM.utubeAuth);
c.setRequestProperty("X-GData-Client", appM.clientid);
c.setRequestProperty("X-GData-Key", "key="+appM.developerkey);
c.setRequestProperty("Slug", "myvideo.3gp");
c.setRequestProperty("Content-Type", "multipart/related; boundary="+BOUNDARY);
// String consize=new String()


String message1 = "";
message1 += "--"+BOUNDARY + CrLf;
message1 += "Content-Type: application/atom+xml; charset=UTF-8" + CrLf+ CrLf;
message1 += axml;
message1 += CrLf+"--"+BOUNDARY + CrLf;
message1 += "Content-Type: video/3gpp" + CrLf;
message1 += "Content-Transfer-Encoding: binary" + CrLf+ CrLf;
// the image is sent between the messages in the multipart message.

String message2 = "";
message2 += CrLf+"--"+BOUNDARY + "--";



String contlen=(new Long(appM.blockSize[2]+message1.length()+message2.length())).toString();
c.setRequestProperty("Content-Length", contlen);

c.setRequestProperty("Connection", "close");
os = c.openOutputStream();
os.write(message1.getBytes());


// os.write(appM.anim[2]);
int index = 0;
int size = 1024;
do{
System.out.println("write:" + index);
if((index+size)>appM.anim[2].length){
size = appM.anim[2].length - index;
}
os.write(appM.anim[2], index, size);
index+=size;
}while(index<appM.anim[2].length);

os.write(message2.getBytes());
 
Bartender
Posts: 20149
104
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the exception?
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!