Mix08- Working with Data and Web Services in Silverlight2.
Applications interact with the outside world. mmm?
Mashups and such. ok
Many types of outside data....
- Images
- RSS
- Business services
- Intranet services
- Mashup API's
silverlight1.1 xaml and fun
-no easy way to connect to other services.
What does client code look like?
Custom services.
Recommended uses of services in silverlight
Using silverlight front end connecting to webservice or database directly.
Using C#
void list<product>getproducts (string searchstring)
- Create service
- Define What does
- Add Service reference
- Use the service
Silverlight-Enabled WCF Service
- ServiceContract
- OperationContract
- DataContract
Reference the service
var proxy = new ShoppingServiceClient() [service]
- Default address chosen if no parameters given
- canpass in addresss manually
- but what if the service moves?
- Config support after beta1
Only uses async methods
<GetProductsDataSource/>
migrate from silverlight1.1 on client side
- Remove web references
- do add service reference
- Data format is now SOAP, not JSON
Server-side no need to change!
Using cookie or session data to pass authentication.
silverlight consumes web page authentication.
HttpContext.Current.User = current user
Pull in outside service
Add Service Reference
include:
- Services
- Soap
- Soap internet
- SQL Server Data services
WSDL connection... nice!
No cross domain applications!
mysite.com cannot call yoursite.com using the same authentication mysite.com.
you can hack it using the policy files:
- silverlight policy file clientaccesspolicy.xml
- adobe policy file crossdomain.xml
3rd party authentication using browser based authentication is looked down upon.
Allowed Urls Http and https subject to cross domain rules no ftp or file://URLs
Sockets support for non-HTTP Services:
-originating server only.
Download code:http://code.msdn.microsoft.com/silverlightws
Restrictions:
- No Put,Delete
- Only get success of failure. No debugging? That's not so cool.
- -403 and 404 will not be displayed.
- Redirects:Work(may be blocked in cross-domain)
- Cannot override the browser
- Caching turned off
- http authentication
- read/write cookies.
Access to XML
- XMLReader/XMLWriter
- Ling to XML
- Serialize/DeSerialize
- Build Type
JSON Data Format usage
JavaScriptObjectNotation easy fast to parse.
- Binary XML
- Linq to JSON
- load JSON strings
RSS/Atom feeds
Uses:
- RSS 2.0
- Atom1.0
- Atom Publishing(future)
Looks promising but not fully cooked.