aspose file tools*
The moose likes Java Micro Edition and the fly likes HTTP Post on UMTS stops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "HTTP Post on UMTS stops" Watch "HTTP Post on UMTS stops" New topic
Author

HTTP Post on UMTS stops

Tilman Bender
Greenhorn

Joined: Mar 16, 2008
Posts: 11
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

Joined: Mar 16, 2008
Posts: 11
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
jackie zho
Greenhorn

Joined: May 26, 2008
Posts: 1
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());
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

What's the exception?


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP Post on UMTS stops