SESSION CODE DEV 202 Ron Jacobs Technical Evangelist
SESSION CODE: DEV 202 Ron Jacobs Technical Evangelist Microsoft Corporation http: //blogs. msdn. com/rjacobs
The Web of Services should work the way the Web of Pages works
public class Conference: Data. Service<Conference. Data. Entities> { // This method is called only once to initialize service-wide policies. public static void Initialize. Service(Data. Service. Configuration config) { config. Set. Entity. Set. Access. Rule("*", Entity. Set. Rights. All. Read); config. Data. Service. Behavior. Max. Protocol. Version = Data. Service. Protocol. Version. V 2; } }
public class Conference: Data. Service<Conference. Data. Entities> { // This method is called only once to initialize service-wide policies. public static void Initialize. Service(Data. Service. Configuration config) { config. Set. Entity. Set. Access. Rule("*", Entity. Set. Rights. All. Read); config. Data. Service. Behavior. Max. Protocol. Version = Data. Service. Protocol. Version. V 2; config. Set. Entity. Set. Page. Size("Sessions", 10); config. Set. Entity. Set. Page. Size("Speakers", 5); } }
private void Register. Routes() { Data. Service. Host. Factory factory = new Data. Service. Host. Factory(); Route. Table. Routes. Add( new Service. Route("Conference", factory, typeof(Conference))); }
Channel Model
Resources
public class Session. Data { public int ID { get; set; } public string Title { get; set; } public Date. Time? Date { get; set; } public string Speaker { get; set; } }
Resources URI
URI Template HTTP Method Operation Session/{id} GET Get all sessions Get one session Session/{id}/Speaker Session/{id} GET POST PUT DELETE Gets speaker for session Add a new session Update a session Delete
Resources URI Service
HTTP GET = “~/Sessions/Get. Session? id=123”
HTTP GET = “~/Sessions/123”
HTTP GET = “~/Sessions? start=5&count=7”
public class Global : System. Web. Http. Application { void Application_Start(object sender, Event. Args e) { Register. Routes(); } private void Register. Routes() { Web. Service. Host. Factory factory = new Web. Service. Host. Factory(); Route. Table. Routes. Add( new Service. Route("Sessions", factory, typeof(Session. Service))); } } No. SVC file!
<system. service. Model> <standard. Endpoints> <web. Http. Endpoint> <standard. Endpoint automatic. Format. Selection. Enabled="true" help. Enabled="true" /> </web. Http. Endpoint> </standard. Endpoints> <service. Hosting. Environment asp. Net. Compatibility. Enabled="true" /> </system. service. Model>
http: //www. microsoft. com/visualstudio/en-us/ http: //blogs. msdn. com/b/somasegar/ http: //msdn. com/data http: //blogs. msdn. com/adonet http: //blogs. msdn. com/astoriateam http: //blogs. msdn. com/efdesign
www. microsoft. com/teched www. microsoft. com/learning http: //microsoft. com/technet http: //microsoft. com/msdn
Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31 st http: //northamerica. msteched. com/registration You can also register at the North America 2011 kiosk located at registration Join us in Atlanta next year
- Slides: 40