Web services etc...

polomint

New member
Jan 31, 2013
223
0
0
Could someone point me to the best way to consume web services? I'm actually going to use a web based API to pull information from World of Spectrum using their infoseek engine so that I can show information about zx spectrum games :) buy first I want to get comfortable using web services :)

Any help or pointers would be appreciated.

John
 
I am not to sure on this area however does Microsoft may have some examples I have a look to see if there anything.
 
Thanks for that, I'm trying to find out how to do it via the WP8 API. I'm off to work now, but I shall take a look when I get back this evening, :)
 
Another question.. :)

What is the best way to share data between xaml pages? I can't remember the name but I recall there being an app.xaml.cs file, is it best to place variables in there so that the whole app can use them? I think I did it that way before.

I may just finish early at work just so I can go home and check lol
 
Thanks for that, I'm trying to find out how to do it via the WP8 API. I'm off to work now, but I shall take a look when I get back this evening, :)

Sorry they were desktop thought they were WP, I will take a better look.
 
Last edited:
Just thinking, but we could do with a chat room for devs in here to communicate too, IRC or summat hehe
 
The recommended way to pass information between xaml sheets is using the MVVM architecture where values are expressed as properties that are displayed by xaml components using bindings. However, that being said sometimes it is just easier to have a static public variable as the binding commands in xaml/wpf/Silverlight sometimes are difficult to get to work.

As far as web services, it depends on what web technology they are using ....SOAP, wcf, REST... once you determine that then you should be able to figure out the appropriate way to consume the service.

Rob
 
Thank you for the reply. I think I will go with the static public variable approach this time as its only some simple information to store.
As for the web service, I have noticed that it just returns XML when I send a query so that should be easy enough to sort out too.

Thanks again :)
 
If you want to share data among pages then the best way to do it use the IsolatedStorageSettings. Works in key value pair, Here's how

//initialize above the constructor
IsoatedStorageSettings yourDataDict = IsolatedStorageSettings.ApplicationSettings;

//use it wherever you want to save data
yourDataDict.Add("savedName", tbName.Text);
yourDataDict.Save();

//use the following code to retreive
//you have to cast the retrieved value when you fetch from isolatedstorage
string name = (string)yourDataDict["savedName"];

Hope it helps, the code's from the tip of my tongue so don't fret if you get some errors somewhere.
 
I'll vote for public members in the App.xaml.cs as the easiest like you mentioned... but I wouldn't do this in general. This gets messy the more data you need to pass back and forth. Also I have to disagree with using the IsolatedStorageSettings because it's you're writing to the disk (which could be a slow SD card as of WP8.1) so you can't guarantee performance and things, again, can get messy (don't you have to worry about clearing out those values since they persist across app lifecycles?) I would very much recommend IsolatedStorageSettings, though, if we do want to persist data across different app launches AND across multiple pages.

The proper way (according Microsoft) is to pass data as a query string in WP Silverlight or the parameters object in WinRT when navigating to a page.
How to pass data between pages in Windows Phone: Alternatives | GeekChamp
http://mikaelkoskinen.net/winrt-xam...e-to-page-how-it-differs-from-windows-phone-7
 
If it's just a parameter or two, I'd go with Im_Q's, parameter suggestion. If it's a lot of data, like from that web service you mentioned, save yourself the headache and make a separate class for accessing and managing data so that everything is in one place and it is strongly typed. Presumably you are calling the web service and caching the data to isolated storage. You could instantiate the class at some point when the app loads and assign it to a property in App.xaml.cs to expose it to the whole app, but I like using dependency injection using an MVVM framework like MVVM Light (it's in Nuget). That way you never have to worry when writing your viewmodels wondering where the data repository object is. It gets injected automatically via a property or constructor parameter. It takes a bit of setup, but makes it easier down the line, particularly in complex projects.
 

Members online

No members online now.

Forum statistics

Threads
341,241
Messages
2,264,308
Members
428,833
Latest member
Ovaucretbung