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


MSA ALTAIR 4XR picture

MSA ALTAIR 4XR

$700.00



MSA altair 4X multi gas meter Monitor detector, O2,H2S,CO,LEL Charger calibrated picture

MSA altair 4X multi gas meter Monitor detector, O2,H2S,CO,LEL Charger calibrated

$340.00



MSA Altair 5 Gas Detector  picture

MSA Altair 5 Gas Detector

$98.99



MSA Altair 5X Gas Detector Meter *Recently Calibrated and 30 Day Warranty* picture

MSA Altair 5X Gas Detector Meter *Recently Calibrated and 30 Day Warranty*

$795.00



MSA 10042621 Altair 5X Sampling Probe Straight Air-Line 1' Color Black (E2) picture

MSA 10042621 Altair 5X Sampling Probe Straight Air-Line 1' Color Black (E2)

$295.00



New MSA Altair Pro O2 Gas Detector (Part Number 10074137c) - Open Box picture

New MSA Altair Pro O2 Gas Detector (Part Number 10074137c) - Open Box

$269.99







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