cvandal
cvandal

Reputation: 794

WP7 Getting and storing data from an xml web service for use across the project

How can I get data from an xml web service (say, the value of an element) and then store that data so that it can be used throughout the project?

Update:

To clarify, I need to get the value from an element in the following web service uri. "http://web-service-address.com"

Then, I need to be able to use that value in another web service uri. "http://web-service-address.com/" + stored_value + "/service"

Upvotes: 2

Views: 787

Answers (3)

Mick N
Mick N

Reputation: 14882

It is wise to be cautious with potentially senstive data such as username/passwords and I'm pleased to see the documentation is now alerting developers to this.

Security and convenience are requirements to be weighed in the context of the sensitivity of the data that is being protected.

Just making it a bit more difficult to obtain a person's credentials may be sufficient in some applications to deter people from making the effort to bypass security measures, particularly if the value of the data or services being protected is low. In this case, offering the convenience of saving credentials for your user may be appreciated.

On the other hand, the data/services being protected may be of high sensitivity/value and concerns of the users phone being physicaly compromised or compromised by unsecure software not obtained via the marketplace may be genuine.

If you are in any doubt, and want to defer the decision to your user, you can always do this by alerting them to the risks and offering them the choice - as browsers and websites do with offering to save your credentials.

Either way, this is for you to evaluate in the context of your app.

With regard to where data can be stored, Isolated Storage is the place to look.

As Matt has suggested, Isolated Storage Settings is an approachable place to start, with some of the lifting done for you.

Alternatively you may like to just write a file in a format of your own choosing to Isolated Storage. Documentation for all of this is available here.

Isolated Storage for Windows Phone

Isolated Storage Overview for Windows Phone

How to: Add Files and Folders for Windows Phone

System.IO.IsolatedStorage Namespace ()

Upvotes: 1

mattStroshane
mattStroshane

Reputation: 221

We recently updated the Windows Phone Developer documentation with guidance specifically related to using Web Services in windows phone apps. There is also a topic about best practices for security. I hope the following link helps:

http://msdn.microsoft.com/en-us/library/gg521151(v=VS.92).aspx

Upvotes: 0

Matt Lacey
Matt Lacey

Reputation: 65566

Firstly, don't store passwords! EVER!

From the other question you just asked, you know how to get the data from the XML.

If you need to persist data across multiple executions of an app then you should save this to IsolatedStorage. For your specific scenario I'd recommend using IsolatedStorageSettings.

var settings = IsolatedStorageSettings.ApplicationSettings;
settings.Add("id", myid);

then access it via

if (settings.Contains("id"))
{
    string stored_value = settings.["id"].ToString();
}

Upvotes: 2

Related Questions