problems calling webservices through the https connection
Posted
by shivaji123
on Stack Overflow
See other posts from Stack Overflow
or by shivaji123
Published on 2010-04-07T12:09:20Z
Indexed on
2010/04/07
12:13 UTC
Read the original article
Hit count: 280
blackberry
i have done an application in BlackBerry which takes username & password with url link which is a link of server here i am calling some webservices but it is doing the connection in https so when i take the username password & url link & hit the login button it basically calls a webservice but then the application connecting to the webservice for ever & after some time i get the error massage something "unreported exception the application is not responding" .& then the application crashes out.Also i am using the SOAP client library .
this is the piece of code
synchronized (this)
{
try
{
_httpconn = (HttpConnection) Connector.open(url,Connector.READ_WRITE);//Connector.READ_WRITE
//_httpconn =(StreamConnection)Connector.open(url);
//System.out.println("-----------httpsconnection() PART--------------------");
_httpconn.setRequestMethod(HttpConnection.POST);
//_httpconn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
//System.out.println("-----------httpsconnection() PART- **-------------------");
_httpconn.setRequestProperty("SOAPAction", Constants.EXIST_STR);
//System.out.println("-----------httpsconnection() PART-REQUEST -------------------");
_httpconn.setRequestProperty("Content-Type", "text/soap+xml");
//System.out.println("-----------httpsconnection() PART- CONTENT-------------------");
_httpconn.setRequestProperty("User-Agent", "kSOAP/1.0");
//System.out.println("-----------httpsconnection() PART-USER Agent-------------------");
String clen = Integer.toBinaryString(input.length());
_httpconn.setRequestProperty("Content-Length", clen);
//System.out.println("-----------httpsconnection() Content-Length--------------------");
_out = _httpconn.openDataOutputStream();
//System.out.println(input+"-----------input--------------------"+url);
_out.write(input.getBytes());
_out.flush(); // may or may not be needed.
//int rc = _httpconn.getResponseCode();
int rc = _httpconn.getResponseCode();
if(rc == HttpConnection.HTTP_OK)
{
isComplete = true;
_in = _httpconn.openInputStream();
msg = new StringBuffer();
byte[] data = new byte[1024];
int len = 0;
int size = 0;
while ( -1 != (len = _in.read(data)) )
{
msg.append(new String(data, 0, len));
size += len;
}
responsData = msg.toString();
System.out.println("-----------responsData "+responsData);
}
if(responsData!=null)
isSuccessful = true;
stop();
}
catch (InterruptedIOException interrIO)
{
//errStr = "Network Connection hasn't succedded. "+
//"Please check APN setting.";
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
Status.show("Network Connection hasn't succedded. "+
"Please try again later.");
}
});
isComplete = true;
System.out.println(interrIO);
stop();
}
catch (IOException interrIO)
{
System.out.println("-----------IO EXCEPTION--------- "+interrIO);
//errStr = "Network Connection hasn't succedded. "+
//"Please check APN setting." ;
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
Status.show("Network Connection hasn't succedded. "+
"Please try again later." );
}
});
isComplete = true;
System.out.println(interrIO);
stop();
}
catch (Exception e)
{
System.out.println(e);
//errStr = "Unable to connect to the internet at this time. "+
//"Please try again later.";
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
Status.show("Unable to connect to the internet at this time. "+
"Please try again later." );
}
});
isComplete = true;
stop();
}
finally
{
try
{
if(_httpconn != null)
{
_httpconn.close();
_httpconn = null;
}
if(_in != null)
{
_in.close();
_in = null;
}
if(_out != null)
{
_out.close();
_out = null;
}
}
catch(Exception e)
{
System.out.println(e);
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
Status.show("Unable to connect to the internet at this time. "+
"Please try again later." );
}
});
}
}
}
}
can anybody help me out.
Thanks in advance
© Stack Overflow or respective owner