250 likes | 290 Views
Web Development Tools. 6.916 Lecture Thursday, October 19, 2000 Jim Miller (Microsoft). Web Site Review. Design HTML Decide where it’s not static Write code to parse incoming URL Write code to generate HTML page If you need state, use a data base If you need session state ...
E N D
Web Development Tools 6.916 Lecture Thursday, October 19, 2000 Jim Miller (Microsoft)
Web Site Review • Design HTML • Decide where it’s not static • Write code to parse incoming URL • Write code to generate HTML page • If you need state, use a data base • If you need session state ... • … use a cookie (client side)? • … encode in URL? • … store in data base, use URL (server side)
? What’s the Structure? Browser Shopping Service Supplier 1 HTTP / HTML Supplier 2 Idea:A Web Service is a Web site that provides a programmatic interface. Customer Data and Credentials Supplier 3 Merchandise, Prices, and Discounts
Web Service Review Service Side • Write the service code • Expects SOAP as input • Define the externally visible methods • Create the WSDL description of those methods • Publish the WSDL • Run the service Client Side • Locate the WSDL • Load the WSDL • Convert to a client proxy • Write the client code, calling proxy • Generates and sends SOAP
How Do You Find a Web Service? • Use the Web – someone ought to build a portal • Ask a Server – someone ought to standardize a “request for service description” • Provide a “well-known Web Service” • “Portal for programs, not people” • Categorize services • Who decides the categories • Can a service be in multiple categories? • What about business arrangements? • Take a look at http://uddi.org
What About the Client? • Use a browser • “just” HTML • client-side scripts • download “controls” • Write a custom application • Use HTTP to connect • Use HTML, XML, SOAP, etc. as payload • Communicate via “side channel” to other sources
Isn’t This Complicated? • Why not separate HTML from code? • Why not program in your favorite language, or languages? • Why not have rich, programmable tags? • Why write the WSDL at all? • Why not program with objects instead of SOAP strings? • What about multiple clients? • Isn’t it a pain to write separate code for each kind? • But doesn’t it look ugly and run slow if you don’t? • …and what about “odd” devices like cell phones
Trivial Web Page Demo • You all know how to do this -- http://localhost/jsm.aspx • Let’s see how it looks in ASP.NET … • It would look the same even for a cell phone • I didn’t write any state maintenance code • From my point of view, there are just objects with state • Behind the scenes, of course, it’s the same old stuff… • I’ve combined the HTML and script code, but that’s not necessary and isn’t a good idea for large Web sites
Trivial Page (HTML) <html> <body> <center> <form method="post" runat="server"> Type your first and last name: <asp:textbox id="Name" runat="server"/> <asp:button type=submit text="Hello" OnClick="SubmitBtn_Click“ runat="server"/> <BR> <asp:label id="FirstName" runat="server"/> <BR> <asp:label id="LastName" runat="server"/> <p> </form> </center> </body> ... See next slide
Trivial Page (Script) <script language="C#" runat=server> void SubmitBtn_Click(Object sender, EventArgs e) { String[] Parts = Name.Text.Split(new char [] {' '}); FirstName.Text = "First name: " + Parts[0]; LastName.Text = "Last name: "; for (int i=1; i < Parts.Length; i++) LastName.Text += Parts[i]; } </script> </html>
What’s This <asp: Stuff? • ASP.NET is a Web server, the successor to ASP • Basic model is static pages • Instructions to the server are embedded in HTML • <asp: … runat=server> indicates a “server-side control” • Tests for client, generates either HTML or DHTML or WAP or … • Programmable in two ways • Via the HTML • Via programs in any number of languages, appearing as objects (with fields, methods, state, and attributes) • While Microsoft ships a large number of these “server controls” • All the APIs to do it are public • We ship several source code samples • We want to start a market for third party controls
Documentation on Label <asp:label id="FirstName" runat="server"/> FirstName.Text = "First name: " + Parts[0];
How Does Scripting Work? • We don’t want to restrict the choice of language • We don’t want to restrict the operations available on the embedded controls • We want a rich set of operations with default behavior • ASP.Net defines • An object model for Web pages • An object model for Web controls • An object model for plugging in languages • Underneath, there’s a Common Language Runtime
Common Language Runtime Frameworks Base Classes Common Language Runtime ExecutionSupport Security IL to native code compilers GC, stack walk, code manager Class loader and layout
Execution Model VB VC ... Script NativeCode Install timeCode Gen IL Common Language Runtime “Econo”-JITCompiler Standard JITCompiler NativeCode
Key to simpler programming model Generated automatically Stored with code in executable file (.dll or .exe) Uses existing COFF format Via existing extension mechanism Stored in binary format Convertible to/from XML Schema Convertible to/from COM type libraries Metadata
What’s In The Metadata • Description of deployment unit (assembly) • Identity: name, version, culture[, public key] • What types are exported • What other assemblies it depends on • Security permissions needed to run • Description of types • Name, visibility, base class, interfaces implemented • Members (methods, fields, properties, events, nested types) • Custom attributes • User-defined • Compiler-defined • Framework-defined
Metadata: Creation And Use Reflection Source Code Serialization (e.g. SOAP) Designers Compiler Other Compiler Debugger Metadata (and code) Type Browser Profiler Proxy Generator Schema Generator XML encoding (SDL or SUDS)
Runtime Control Flow Assembly ClassLoader First reference to type IL to nativecode compiler ExecutionSupport ManagedNativeCode First call to method CodeManagers SecuritySystem CPU
Compiling IL To Native • “Econo” JIT • Generates unoptimized native code • Code can be discarded and regenerated • “Standard” JIT • Generates optimized native code • Includes verification of IL code • Install time code generation • Done at install time • Reduces start-up time • Native code has version checks and reverts to runtime JIT if they fail
Managed Code • Managed code provides... • Metadata describing data • Location of references to objects • Exception handling tables • So runtime can provide… • Exception handling • Security • Automatic lifetime management • Debugging and profiling
Managed Data • Layout Provided by Runtime • Usually automatic • Metadata can specify • Order • Packing • Explicit layout • Lifetime Managed by Runtime (GC) • Working set is compacted • Data is moved • Object references are updated • No more intrusive than a page fault
Calling Unmanaged Code Unmanaged NativeCode Common Language Runtime “Econo”-JITCompiler Standard JITCompiler Managed NativeCode
Crossing The Boundary • Mode transition for code manager • Calling conventions differ on x86 • Fast, rarely more than register shuffle • Data type marshalling • Representations may not be the same • Pinning, copying, and/or reformatting needed • Custom marshalling supported • The IL to native compilers help • In-line code transition and simple marshalling • Per call site cost is very low • Plus a small cost on entry to a procedure that can make calls across boundary
What’s Really Happening • When ASP.Net notices a new page, it calls the appropriate compiler to generate IL and metadata • The IL is compiled to native code • The native code runs • In addition to the regular URL there is a query form used to retrieve the WSDL • When the WSDL is requested the metadata is converted to WSDL, cached, and returned • There are tools that convert WSDL into proxy programs so clients can access the service • When SOAP is sent to the service, it is converted to objects as described in the WSDL and passed to the service code