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
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Request working on the simulator but not on the BB

[ Edited ]

Hi everyone,

 

I have a program sending a request and parsing the response.

When I run it on the simulator with an MDS server running, everything is fine.

 

However, when I try it on the Blackberry, I send the request. See the arrows in the upper-right side of the blackberry telling that data is being sent and received. But then I get an error during the parsing because the response is empty (when I display it, i have an empty string).

 

The BB is connected to the internet as I can access google.com through the browser.

Do you know where it might come from?

 

I'm sorry if I ask dummy questions but I'm taking over someone else's job and am totally new to BB.

 

(PS: This request is not related to the one I'm referring to in my other thread)

Message Edited by yann247 on 03-19-2009 10:59 AM
Message Edited by yann247 on 03-19-2009 11:29 AM
Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: Program working on the simulator but not on the BB

As you said, you recieved an empty string as response and you try to parse it then might be you are try to get something out of string in your parsing algo but you will get exception bcoz nothign is there in string. Please put a condition in start of your parsing algo like If(!str.equals(""))

 

 


Press the kudos button to thank the user who helped you.

If your problem was get solved then please mark the thread as "Accepted solution".

 

 

 

 

Deepesh Gupta
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Program working on the simulator but not on the BB

I know but that's my problem. The string is NOT supposed to be empty and I need it to continue the program so I can't just ignore the parsing if the string is empty.

 

And as I said the string is not empty when I run the whole thing on the simulator.

 

Here is the code btw

 

SoapObject request = new SoapObject(namespace, "OasXmlRequest"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); request.addProperty("String_1", user.getAccount()); request.addProperty("String_2", user.getLogin()); request.addProperty("String_3", user.getPassword()); request.addProperty("String_4", requestBody); envelope.setOutputSoapObject(request); try { HttpTransport ht = new HttpTransport(user.getUrl() + "/oasapi/OaxApi?wsdl"); ht.call(null, envelope); result = (envelope.getResponse()).toString();

 

Then the parsing

 

SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); InputStream in = new ByteArrayInputStream(result.getBytes()); saxParser.parse(in, handler); errorMsg = handler.getError(); } catch (SAXParseException ex) { errorMsg = "SAXParseException " + ex.getMessage() + ", Line:" + ex.getLineNumber() + ", colums:" + ex.getColumnNumber() + ", publicid:" + ex.getPublicId() + ", systemid:" + ex.getSystemId() + ", was parsing:" + result;

Exception only happens on the BB, and the messages gets me: -1 for line, -1 for column, null for public id and system id, "" for result.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Program working on the simulator but not on the BB

Your actual communication is well hidden under the SOAP processing, but can you tell if it is successful or not?  I'm concerned that your are getting an exception or timeout, which is why you are not getting anything back.

 

The URL you are using probably has no connection suffix, which means it will work in DES/MDS situations.  In the Simulator this is what you are creating.  But is your real device a BES or BIS device.  In other words, is it a corporate or consumer device.  If it is a corporate device, then BES/MDS connection will work, if not BES/MDS will not work and you will have to specify a suffix in your URL.  You can find out more about this in these links:

 

What Is - Different ways to make an HTTP or socket connection
Article Number: DB-00396

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

 

Network Transports video:

http://www.blackberry.com/DevMediaLibrary/view.do?name=NetworkingTransports

 

Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Program working on the simulator but not on the BB

How can I tell if it is sucessful? I've already surronded the call by a try/catch.

 

The url is: https://xxx.domain.com. My device has been given to me by my company so I figure its a BES device. So it's supposed to work right?

 

What am I missing?

 

Thanks,

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Program working on the simulator but not on the BB

"My device has been given to me by my company so I figure its a BES device."

Probably - does it have a company email address?  If you go into Options-Advanced do you see Enterprise Activation?  If the answer to both is yes, then I think it is - don't know if these are conclusive, but I see these on my device which is a BES device.

 

" So it's supposed to work right?"

Correct, if it is a BES device, you shouldn't need a suffix.

 

"What am I missing?"

Good question, it is a long time since I played with SOAP, so I'm sorry I can't help more.  Hopefully someone else can.

Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Program working on the simulator but not on the BB

Check and check, so it looks like it's a BES device.

So I'm still lost... But thanks anyway

 

If anybody has an idea on why its working on the simulator but not on the actual phone...

 

thanks,

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Program working on the simulator but not on the BB

Do you have access to the BlackBerry Enterprise Server?  If so, you can enable verbose HTTP and HTML logging for the MDS Connection Service and check the log file to see the data that was sent.  This will allow you to verify what the web service has returned.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Program working on the simulator but not on the BB

Unfortunately I dont...

any other way?

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Program working on the simulator but not on the BB

Do you have access to the machine running the web service?  If so you could try setting up a network capture.  Have you tried another BlackBerry handheld on the same BlackBerry Enterprise Server?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker