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

Web and WebWorks Development

Reply
Contributor
ShailJoshi
Posts: 19
Registered: ‎04-05-2011
My Device: Storm2 9550

Web Service Call in Blackberry Widget Application using RESTFul webservice with JSON Method

Could anybody tell me how to use RESTFul WebService with JSON method in Blackberry widget application to send and recieve object.I have an application where I need to send some form data(search criteria) as an object from my BB mobile which is recieved at the server end using RESTFul method ,compare the criteria from database and send result back as an JSON object that is displayed on my result screen of mobile.I am using XMLHttp Request method to connect to server.Here at forum I found an Sample code as "Lab Mobile engineer" that is similar to my requirement but it uses SOAP Web Service.

 

Thanks in Advance.

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Web Service Call in Blackberry Widget Application using RESTFul webservice with JSON Method

Have you had a chance to check out the below thread that?  We've sticky'd it at the top of the forum..

 

http://supportforums.blackberry.com/t5/Web-Development/How-quot-I-quot-would-call-a-web-service-from...

 

I think it will answer a lot of your questions :Batman:

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
ShailJoshi
Posts: 19
Registered: ‎04-05-2011
My Device: Storm2 9550

Re: Web Service Call in Blackberry Widget Application using RESTFul webservice with JSON Method

Yes I followed that but this example is using SOAP Web service but I wanna to use RESTful Web SErvice and also compare and fetch data from server database which need to be send using JSON Object to my mobile.

 

Thanks for reply

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Web Service Call in Blackberry Widget Application using RESTFul webservice with JSON Method

The example does show soap, but by using some of the settings on the ASP.NET web service it is actually being called restuflly.

 

Essentially the steps are the same:

1) Create a Restful webservice that returns its data as JSON

2) Call the web service URL via AJAX

3) Parse the XMLHttpRequst.responseText using a JSON parser into a JavaScript object

4) Run your logic locally

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
ShailJoshi
Posts: 19
Registered: ‎04-05-2011
My Device: Storm2 9550

Re: Web Service Call in Blackberry Widget Application using RESTFul webservice with JSON Method

and how to send multiple data or object from the mobile app(client side ) to RESTFul web method?with URL or have any other mean?Could you please send me a sample code if u have?

 

As a newbie i need ltl assistance, thanx.

 

 

 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Web Service Call in Blackberry Widget Application using RESTFul webservice with JSON Method

You have various options.. you can expand the call out into multiple parameters in a GET call to the service, or you can post down list data as part of a POST call.  You can even assemble JSON text and send it down as part of a POST.  It all comes down to how you want your RESTful service to work.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
ShailJoshi
Posts: 19
Registered: ‎04-05-2011
My Device: Storm2 9550

Re: Web Service Call in Blackberry Widget Application using RESTFul webservice with JSON Method

Thanks again for reply but i am still stuck over there.

 

Is it possible to send JSON Object using XMLHttpRequest POST method,At server end  I am using RESTFul webservice with RESTEasy framework and default jettinson mapped technique.If it is possible please reply with sample code..

 

Actually when I try to do run my code using above stated method the simulator  displays nothing,although @ browser it diplays the JSON String well.

 

Thanks again.

Please use plain text.