Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Contributor
Posts: 6
Registered: ‎11-16-2012
My Device: 9700
My Carrier: AT&T

wap 2.0 connectivity gateway timeout exception.

Hi,

      I was able to open the url in browser, and when i was trying to connect via wap 2.0 its throwing gateway time out exception , The same code is working for wifii or any other transport type i was facing problem with wap 2.0

please help already wasted 2days for it.

 

ConnectionFactory connFact = new ConnectionFactory();
connFact.setPreferredTransportTypes(preferredTransportTypes);
ConnectionDescriptor connDesc;
connDesc = connFact.getConnection(url);


ByteArrayOutputStream baos;

if (connDesc != null) {
HttpConnection httpConn;
int transportType = connDesc.getTransportDescriptor().getTransportType(); 
ConnectionDescriptor connd = connFact.getConnection(url);
String transportTypeName = TransportInfo.getTransportTypeName(connd.getTransportDescriptor().getTransportType());
System.out.println("----------------2------------transportTypeName------"+transportTypeName + connd.getUrl());

 

httpConn = (HttpConnection) connd.getConnection();
try {

byte[] postData = encPostData.toString().getBytes("UTF-8");

httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE, HttpProtocolConstants.CONTENT_TYPE_MULTIPART_FORM_DATA);
httpConn.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LENGTH, String.valueOf(postData.length));


OutputStream os = httpConn.openOutputStream();
os.write(postData);
os.flush();


StringBuffer sb = new StringBuffer();
int responseCode = httpConn.getResponseCode();