BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 02-11-2005, 04:15 AM   #1
zoe
New Member
 
Join Date: Feb 2005
Posts: 1
Default Http Web Service Request Freezes

Please Login to Remove!

Hi, if anyone has any ideas

I'm making a http request to a web service, this works fine on the simulator and fine when run on the handheld as a UI Application. BUT when I run it as a background thread on startup the handheld 7230 freezes. I have found clues that its because i'm trying to connect from the main thread and the connection message can't show, but I've tried various ways of coding this and it still freezes on this line s = (StreamConnection)Connector.open(url);

I've searched the forum and can't really find any specific answers or code examples. The error I get is no sig from 0x33. My code is signed and i've set theApp.setAcceptEvents(false); I'll post my code below, if anyone could take a quick look. I can't really find any examples anywhere to take a look at!!! Thanks Zoe

public static void main(String[] args){

TimeSynchro theApp = new TimeSynchro();
theApp.enterEventDispatcher();
theApp.setAcceptEvents(false);
boolean event = theApp.isEventThread();
}

public TimeSynchro()
{
TimeSynchroThread updateTime = new TimeSynchroThread();
Thread syncTime = new Thread(updateTime);
syncTime.start();
}


public static class TimeSynchroThread implements Runnable
{
private HttpConnection conn;
private StreamConnection s;
private DataInputStream is;
private DataOutputStream out;
private String url = "http://*.*.*.*.*/FirstService/FirstService.asmx";

public void run(){

while(true){

try{

synchronized(this){

// Only Request if radio state and signal ok
int state = RadioInfo.getState();
int level = RadioInfo.getSignalLevel();

if((state == 1) && (level > -121 ) && (level < -51)){

String soapRequest = buildXML();

s = (StreamConnection)Connector.open(url);
conn = (HttpConnection)s;

byte[] requestXML = soapRequest.getBytes();

// Set the appropriate HTTP parameters.
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty("Content-Length", String.valueOf(requestXML.length));
conn.setRequestProperty("Content-Type","text/xml; charset=utf-8");
conn.setRequestProperty("SOAPAction","http://tempuri.org/TimeSynchro");
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


50PCS 1S2473 diode DO35 picture

50PCS 1S2473 diode DO35

$28.49



5pcs CL04-12 Microwave Oven High Voltage Diode Rectifier Brand New picture

5pcs CL04-12 Microwave Oven High Voltage Diode Rectifier Brand New

$2.67



10pcs HER508 5A 1000V DO-27 diode picture

10pcs HER508 5A 1000V DO-27 diode

$2.02



5PC DSEI12-10A Fast Recovery Diode 12A1000V DSE112-10A picture

5PC DSEI12-10A Fast Recovery Diode 12A1000V DSE112-10A

$2.77



100 Pcs 1N4148 100v Fast Switching Glass Diode 1N914 | DO-35 Axial | US Ship picture

100 Pcs 1N4148 100v Fast Switching Glass Diode 1N914 | DO-35 Axial | US Ship

$8.62



5Pcs 1000V 50A Metal Case Single Phase Diode Bridge Rectifier KBPC5010 5X picture

5Pcs 1000V 50A Metal Case Single Phase Diode Bridge Rectifier KBPC5010 5X

$9.89







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.