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


OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5 picture

OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5

$13.81



DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X  - Made By DELL picture

DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X - Made By DELL

$39.98



Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M picture

Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M

$2.95



OEM Dell Precision M3800 XPS 15.6

OEM Dell Precision M3800 XPS 15.6" 15-9530 CPU Left Fan 2PH36 NIA01 DC28000DQF0

$9.99



Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI picture

Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI

$94.99



OEM Dell 3310 2 in 1 LCD Touch Screen D2TNH NV133FHM-T00 06GHX8 picture

OEM Dell 3310 2 in 1 LCD Touch Screen D2TNH NV133FHM-T00 06GHX8

$54.00







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