2010 - Basta!: REST mit WCF 4, Silverlight und AJAX
-
Upload
daniel-fisher -
Category
Software
-
view
279 -
download
0
Transcript of 2010 - Basta!: REST mit WCF 4, Silverlight und AJAX
Services in the WebREST mit WCF 4, Silverlight und AJAX
Daniel Fisher (lennybacon) | devcoach.com
Lennybacon.com■ Daniel Fisher | CTO & Software Architect ■
MCP, MCTS, MCPD…[email protected]
■ Mit-Gründer und Geschäftsführer von devcoach.comwww.devcoach.com
■ Mit-Gründer und Vorstand dergemeinnützigen www.just community.de e.V.
■ Veranstalter des größten Entwickler & IT-Pro Community Events in Deutschland: www.nrwconf.de
■ Mit-Gründer und Leiter derINETA Usergroup Düsseldorf
www.NetUG-NiederRhein.de
■ Mitglied im Microsoft Community Leader & Insider Program (CLIP)
■ Connected Systems Advisory BoardExpertengruppe für WCF, WF & BizTalk
■
Efficient Communication…
devcoach.com■ Leistungen
■ Architektur-BeratungStrukturierter und effizienter zu einer wartbaren Anwendung.
■ Software-EntwicklungTeam-out-of-the-box (Near-shoring)Objektmodelle und DatenzugriffKommunikations-InfrastrukturenIdentitäts- und BerechtigungsmodelleWeb 2.0 und Rich Internet Applikation
■ Coaching & TrainingTechnologien schneller verstehen und richtig einsetzen.
■ Technologien
■ Microsoft Windows & .NET FrameworkASP.NET, WCF, WF, WPF, Silverlight & Geneva
■ Kunden
■ Versicherung, Finanzindustrie, Mittelstand, Handel, Kommunikation, Softwarehersteller u.v.a.Bundesamt für Sicherheit in der Informationstechnologie, Microsoft, Dresdner Bank…
Project Experience
Technology Know-how
devcoach®
Agenda• What is REST?• WCF WebHttp• Consumer
The WCF Eco System
WCF Core
Services
WCF Data
Services
WCF Workflo
w Service
s
WCF WebHtt
p
WCF RIA
Services
What is REST?■ A term coined by Roy Fielding■ Style of architecture■ Resource based■ Cachable■ NOT SOAP, NOR SESSION
■ Web Standards!
What is WebHttp?• A Services flavor• RESTful • Non-SOAP HTTP services• Complete control over the • URI• Format• Protocol
WebHttp v 4.0■ WCF 3.5■ + WCF REST Starter Kit■ + .NET 4■ + new Features
demo!
Attribute Inheritance[ServiceContract]public interface ISessionPlaner{ [OperationContract] [WebGet(UriTemplate = "Sessions")] List<SessionDetail> GetAllSessions();}
Attribute Inheritance[ServiceContract]public interface ISessionPlaner{ [WebGet(UriTemplate = "Sessions")] List<SessionDetail> GetAllSessions();}
DO NOT REPEAT YOURSELF!
No Routing
Routingpublic class Global : System.Web.HttpApplication
{
void Application_Start( object sender, EventArgs e)
{
RouteTable.Routes.Add(
new ServiceRoute(
string.Empty,
new WebServiceHostFactory(),
typeof(SessionPlanerService)));
}
Configuring the Module
<configuration> … <system.web> // <system.webServer> IIS 7 … <httpModules> … <add name="urlRouting" type="System.Web.Routing.UrlRoutingModule"/> </httpModules>…
ASP.NET Routing
Controller
Model
View
RoutingRule
WCF Routing
ServiceHost
Service
RoutingRule
demo!
What about the contract?
Description Attribute[ServiceContract]public interface ISessionPlaner{ [Description("Gets all sessions.")] [WebGet(UriTemplate = "Sessions")] List<SessionDetail> GetAllSessions();}
/help
demo!
Consumer
■ .NET ■ WebRequest■ WebClient■ HttpClient■ WebChannelFactory
■ AJAX■ Silverlight
demo!
Explicit Format Selectionif (WebOperationContext.Current. IncomingRequest.Headers["Accept"] == "application/json")
{ WebOperationContext.Current. OutgoingResponse.Format = WebMessageFormat.Json;
}
Automatic Format Selection<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint
name=""
automaticFormatSelectionEnabled="true">
<security mode="None"/>
demo!
Caching[AspNetCacheProfile("A")]
<system.web> <caching> <outputCache enableOutputCache="true"/> <outputCacheSettings> <outputCacheProfiles> <add name="A" location="Server" duration="60" varyByParam="skip; top; manager" varyByHeader="Accept"/>
Web Faultsthrow new WebFaultException<string>( string.Format( CultureInfo.CurrentCulture, "There is no user with the userName '{0}'.", userName), HttpStatusCode.NotFound);
References■ WCF REST Starter Kit Preview 2 ■ http://
aspnet.codeplex.com/releases/view/24644