Session 7 : The Web - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Session 7 : The Web

Description:

Create a new project of type ASP.NET Web Application. Add some controls. Run from the browser. ... Add the stuff that is needed to make this a web service. ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 24
Provided by: petervi2
Category:
Tags: session | web

less

Transcript and Presenter's Notes

Title: Session 7 : The Web


1
Session 7 The Web
  • Peter Villadsen

2
Matters arising
  • Have I mentioned CodeProject?
  • www.codeproject.com

3
Adding richer content to WinForms
  • The .NET framework is an evolution, not a
    revolution.
  • Before the advent of .NET and managed code, there
    was a concept called COM objects.
  • These were higherlevel versioned objects packaged
    such that the implementation was securely hidden.
  • Subsequently, a standard was defined for COM
    objects with a visual representation (ActiveX).
  • There are A LOT of these out there.
  • Fortunately, it is possible to use these on forms.

4
Demo Controls
  • Demo
  • Agent
  • Spreadsheet
  • MSChart

5
The Web in General
  • The web has revolutionized our lives.
  • It gives us possibilities to reach out into the
    world that we have never had before.
  • It gives businesses a way of conducting business
    electronically.
  • We're only just starting to utilize the potential.

6
Web technologies
  • We will concentrate on
  • Web pages, using ASP.NET
  • Web services.
  • We will not look too much into the technology
    that transports the data from one end to the
    other.
  • (Except maybe for this).

7
The Web Server
  • The web server is the program that sends HTML to
    the browser.
  • The browser requests a page through a URL.
  • The browser uses the DNS (Domain Name Server) to
    convert the domain name of the URL into an IP
    Address.
  • Demo nslookup ltsitegt using IP address in
    browser.
  • The site with that IP address is then hit (on
    port 80).
  • The server examines the rest of the URL
    (stripping the domain) and either just sends the
    HTML back or executes code generating HTML.
  • This is a server, meaning a number of clients can
    be served at once.
  • The MS Internet explorer is called IIS (Internet
    Information Server).

8
HTML. The history
  • In 1989, Tim Berners-Lee worked at CERN in
    Geneva.
  • Particle physics requires cooperation from teams
    all over the world. A method for cross
    referencing and accessing research papers was
    needed.
  • While reading one paper, you could instantly
    examine references to others, forming a web of
    information. The hyperlink was invented.
  • Tim B-Lee based the format of the text on (the
    already existing) SGML. He called it HTML,
    HyperText Markup Language. To transfer the data
    between machines, he invented HTTP, HyperText
    Transfer Protocol.

9
HTML
  • HTML is now a standard. There are many browsers
    available on any platform.
  • HTML is raw text, with tags defining the layout.
  • Demo
  • This servers perfectly for static contents, where
    the information does not change much.
  • Active Server Pages emerged from MS (and other
    technologies from other vendors), allowing code
    to be mixed in.
  • The current incarnation is ASP.NET, allowing
    managed code to be used to provide the code.

10
Dynamic ASPX pages
  • Demo. Make a simple html page and put it in a
    suitable directory.
  • Demo. Take the html page from before and make it
    dynamic, such that it uses code to achieve its
    result.
  • Rename to .aspx
  • Insert code with lt gt metatags.
  • If you wanted to, you could still write code this
    way, but now there are easier and better ways,
    using VS.
  • Now, you can use the knowledge you have from
    building windows forms to build web forms.
  • Works by adding Server controls that are
    interpreted at the server. The generated HTML
    code is sent back to the browser.

11
Source code
  • It is still perfectly possible to mix in code
    with the page itself.
  • In this way, everything is collected in one
    place.
  • BUT It causes a dangerous coupling between
    content and logic.
  • Better to use code behind files (or partial
    classes).

lthtmlgt ltscript language"C" runatservergt
void SubmitBtn_Click(Object sender,
EventArgs e) Message.Text "Hi "
Server.HtmlEncode(Name.Text) ", you selected "
Category.SelectedItem " on "
MyCal.Date.ToShortDateString()
lt/scriptgt ltbodygt ltcentergt
ltform action"intro7.aspx" method"post"
runat"server"gt ....
ltaspbutton text"Lookup" OnClick"SubmitBtn_Click
" runat"server"/gt lt/formgt
lt/centergt lt/bodygt lt/htmlgt
12
Server controls
  • The use of server controls allows user interfaces
    to be written more easily.

lthtmlgt ltheadgt ltlink rel"stylesheet"href
"intro.css"gt lt/headgt ltbodygt
ltcentergt ltform action"intro5.aspx"
method"post" runat"server"gt
ltaspadrotator AdvertisementFile"ads.xml"
BorderColor"black" BorderWidth1
runat"server"/gt lth3gt Name
ltasptextbox id"Name" runat"server"/gt
Category ltaspdropdownlist id"Category"
runatservergt
ltasplistitem gtpsychologylt/asplistitemgt
ltasplistitem gtbusinesslt/asplisti
temgt ltasplistitem
gtpopular_complt/asplistitemgt
lt/aspdropdownlistgt lt/h3gt
ltaspbutton text"Lookup" runat"server"/gt
lt/formgt lt/centergt lt/bodygt lt/htmlgt
13
Demo Writing a Web page
  • Create a new project of type ASP.NET Web
    Application.
  • Add some controls.
  • Run from the browser.
  • Check the application within the IIS.

14
Web Services
  • XML Web services provide a simple, flexible,
    standards-based model for binding applications
    together over the Internet. Middle-tier business
    functionality exposed by way of standard Web
    protocols is known as XML Web services.
  • All implementation details are encapsulated.
  • Web services accept SOAP messages and send back
    SOAP replies.
  • Their interface is described in a special XML
    document with the extension WSDL.
  • This information may be read by interested
    clients who then know how to interact with it.

15
Web Services
  • UDDI specifies a mechanism for Web service
    providers to advertise the existence of their Web
    services, and for Web service consumers to locate
    Web services of interest.
  • It is extremely easy to create web services and
    web services consumers using VS.NET.

16
SOAP
  • Simple Object Access Protocol is the format of
    the messages that go over the wire to invoke web
    services.
  • This is an XML schema.
  • SOAP messages carry both an envelope and a
    payload.
  • ltenvEnvelope xmlnsenv"http//www.w3.org/2003/05
    /soap-envelope"gt
  • ltenvHeadergt
  • lt/envHeadergt
  • ltenvBodygt
  • ltmalert xmlnsm"http//example.org/alert
    "gt
  • ltmmsggtPick up Mary at school at
    2pmlt/mmsggt
  • lt/malertgt
  • lt/envBodygt
  • lt/envEnvelopegt

17
WSDL
  • Web Service Description Language
  • This is the document that describes the web
    service. It contains the following sections
  • Types
  • Messages
  • Operations
  • Port types
  • Bindings
  • Ports
  • Services

18
WSDL
  • Types describe the types of the data contained in
    the messages.
  • This is usually described in the XSD (schema
    definition language).
  • Messages are composed of parts.
  • Each part refers to a type in the Types section.
  • A Port Type is a set of messages grouped into
    operations.
  • Operations represent a single unit of work
    performed by the service. Think of an operations
    as a method with in, out parameters and exception
    cases.
  • Bindings define how a given operation maps to a
    specific protocol.
  • A Port associates a bindig with a protocol
    specific address

19
Demo
  • Create a simple class and put it in a suitable
    web server directory.
  • Add the stuff that is needed to make this a web
    service.
  • Demonstrate that it works.
  • Use the VS IDE to do the same
  • Create a simple web service (call it
    SimpleValidator) to validate a credit card
    number.
  • View the .asmx file in the browser.
  • Show the WSDL in the browser
  • http//localhost/SimpleValidator/Service1.asmx?
    WSDL.

20
Web Services Clients
  • Clients (consumers of web services) certainly do
    not want to deal with the low-level plumbing
    involved in constructing SOAP messages,
    marshalling parameters etc.
  • An clean object model is presented instead.
  • The bridge between the two worlds is the Proxy.
  • The proxy is generated by the wsdl tool.
  • (This is done by the VS environment for you).

21
Demo
  • Create the proxy file for the web service written
    before.
  • Wsdl http//.../MyService.asmx?wsdl

22
Proxy
  • The generated proxy is what supplies the clean OO
    abstraction of the web service.

23
Client
  • The Mappoint web service
Write a Comment
User Comments (0)
About PowerShow.com