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
New Contributor
ankit1_nandekar
Posts: 9
Registered: ‎05-09-2013
My Device: blackberry curve
My Carrier: 9970175907

apn not specified blackberry

hi i am new in blackberry development my app working fine on simulator but when i have deployed this on blackberry its showing apn not specified error.

                        on my client device internet is working properly without apn setting so is it a complasary to confiure apn setting ?

I have append deviceside=true on my webservice url.

 

 

Please use plain text.
Developer
simon_hain
Posts: 15,956
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: apn not specified blackberry

i would suggest to use ConnectionFactory
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
ankit1_nandekar
Posts: 9
Registered: ‎05-09-2013
My Device: blackberry curve
My Carrier: 9970175907

Re: apn not specified blackberry

thanks for your valuable reply i am using following code to cosume webservice is it right? its working fine on simulator

 

HttpConnection http = null;
InputStream iStrm = null;
String _Response = null;
try {

http = (HttpConnection) Connector.open(url);

http.setRequestMethod(HttpConnection.GET);

iStrm = http.openInputStream();

if (http.getResponseCode() == HttpConnection.HTTP_OK) {

int length = (int) http.getLength();

if (length != -1) {
byte servletData[] = new byte[length];
iStrm.read(servletData);
_Response = new String(servletData);

}
}

Please use plain text.
Developer
simon_hain
Posts: 15,956
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: apn not specified blackberry

i generally suggest to use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/io/IOUtilities.html#streamToBy...

getLength may or may not be supported, so you can run into issues there.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: apn not specified blackberry

Since you have not used ConnectionFactory, you are going to have to set your own connection suffix depending on what you want to use.,  On the Simulator you can set nothing, deviceside-true or even interface-wifi depending on what connection options you have enabled and on whether the MDS is running.  On a real device you will have to determine this for yourself.  My strong recommendation is that you change this code to use ConnectionFactory and let the supplied RIM code actually figure out the best connection method for you. 

Please use plain text.
New Contributor
ankit1_nandekar
Posts: 9
Registered: ‎05-09-2013
My Device: blackberry curve
My Carrier: 9970175907

Re: apn not specified blackberry

thnx peter could you please send me sample codet to consume webservice using connectionfactory class

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified
Please use plain text.
New Contributor
ankit1_nandekar
Posts: 9
Registered: ‎05-09-2013
My Device: blackberry curve
My Carrier: 9970175907

Re: apn not specified blackberry

hi,

i have modified my code like

private String GetResponse(String url) {

// Dialog.alert(url);

HttpConnection http = null;
InputStream iStrm = null;
String _Response = null;

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




try {

//http = (HttpConnection) Connector.open(url);
http = (HttpConnection)connDesc.getConnection();

http.setRequestMethod(HttpConnection.GET);
// Dialog.alert(http.getResponseCode()+"");
iStrm = http.openInputStream();

if (http.getResponseCode() == HttpConnection.HTTP_OK) {

int length = (int) http.getLength();
// Dialog.alert(length+"");
if (length != -1) {
byte servletData[] = new byte[length];
iStrm.read(servletData);
_Response = new String(servletData);
}
}
} catch (Exception ex) {
Dialog.alert(ex.getMessage());

} finally {
try {
if (iStrm != null) {
iStrm.close();
}
if (http != null) {
http.close();
}
} catch (IOException ex) {
}
}
return _Response;
}

 

i am getting tcp timeout error

Please use plain text.
Developer
simon_hain
Posts: 15,956
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: apn not specified blackberry

seeing all the dialog alerts and the return string: you should execute networking on a separate thread. see
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

to analyze network issues you can use
http://supportforums.blackberry.com/t5/Java-Development/Network-Diagnostic-Tool/ta-p/445964
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: apn not specified blackberry

Which connection method did your code actually use?

 

This might be useful:

http://docs.blackberry.com/en/developers/deliverables/11938/CS_display_available_transport_types_834...

 

Also you should review the ConnectionFactory API rather than just pasting in code.  You will find using that API you can control the connection types that your app will use and the order it will try them in. 

 

You will find other Threads on the forum that will help too, like this one:

http://supportforums.blackberry.com/t5/Java-Development/ConnectionFactory-Timeout/m-p/1790595#M20324...

Please use plain text.