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


1pcs used TSXMFPP128K Memory Card picture

1pcs used TSXMFPP128K Memory Card

$175.00



Lot Of 2 Samsung ESD DIMM DDR Memory Tray 25 Pcs DDR2 DDR3 DDR4 w/ Original Box picture

Lot Of 2 Samsung ESD DIMM DDR Memory Tray 25 Pcs DDR2 DDR3 DDR4 w/ Original Box

$10.50



2 - RAM DRAM Tray-Container Box For Server PC Memory DIMM Modules - Fits 100 NEW picture

2 - RAM DRAM Tray-Container Box For Server PC Memory DIMM Modules - Fits 100 NEW

$21.90



Desktop Memory Case Tray Case for PC DDR DRAM RAM DIMM Modules - 2 fits 100 New picture

Desktop Memory Case Tray Case for PC DDR DRAM RAM DIMM Modules - 2 fits 100 New

$20.50



WIFI Audio Voice Recorder Live Real-Time Audio Thru App | Charger & 32GB SD Card picture

WIFI Audio Voice Recorder Live Real-Time Audio Thru App | Charger & 32GB SD Card

$129.00



NEW RELIANCE 64K 57C413B COMMON MEMORY MODULE REV 05  picture

NEW RELIANCE 64K 57C413B COMMON MEMORY MODULE REV 05

$459.97







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