• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Web Services (Powerpoint)

Web Services (Powerpoint)






Total Views
Views on SlideShare
Embed Views



4 Embeds 133

http://www.ustudy.in 123
http://ustudy.in 8
http://www.slideshare.net 1
http://translate.googleusercontent.com 1



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.


11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • oui bien mais je veux en français pas en anglais
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Web Services (Powerpoint) Web Services (Powerpoint) Presentation Transcript

    • Web Services
    • What are they?
      • Web services are a platform independent way to exchange data using XML. They are components of business logic that can be accessed over the Internet. They are a way of re-using someone else’s logic without re-creating it yourself. Peter McIntyre’s blog about web services
    • Examples
      • An e-commerce company can use a shipper’s web service to calculate the exact cost of a shipment.
      • National weather forecasters use them to supply data to web-sites and news organizations.
      • Stock prices are provided this way by major exchanges and corporations.
    • Benefits of Web Services
      • Simple – easily supported on many platforms
      • Loosely Coupled – the interface can be extended and new methods added without affecting clients as long as old methods and parameters are still provided
      • Stateless – a request is made, then result is returned and the connection closes, no permanent connection
      • Firewall Friendly – uses HTTP, not usually blocked
    • When to use Web Services
      • Cross platform – i.e. Communicate between a Java app and a .NET app
      • Cross trust boundaries – between two unrelated organizations
      • Future considerations – if there is a possibility that the logic may have to support third party integration
    • When to Avoid Web Services
      • .Net to .Net – there are better ways to communicate between servers, such as .NET remoting
      • .Net Apps – rather than provide a Service, if two apps need the same logic create a class library assembly compiled to a DLL, which is then used in both apps.
    • Discovering and Using Services
      • Right click your project in Solution Explorer
      • Select Add Web Reference
      • In the page that appears input the URL of a web service (.asmx or .wsdl file)
      • When the service is found a listing will appear of all the available methods and a link to Service Description – this is where you find out how the service works
      • Select Add Reference and VS2008 will add all the necessary files to your solution
    • Proxy Class
      • A Web Service communicates with a subscriber using XML and SOAP ( Simple Object Access Protocol ). .NET manages these protocols for you by generating the SOAP message and transmitting it using HTTP. The response is then converted back to the corresponding .NET type.
      • SOAP Tutorial
    • Coding Limitations
      • You can create your web service using any valid .NET code. However there is no interface design because the service is stateless. Parameter and return types are limited to the XML Schema standard such as strings and numbers. You can not pass proprietary .NET objects such as FileStream or an Event Log.
    • Web Service Data Types
      • Simple types – int, unsigned int, float, double, decimal, bool, string, char, byte, DateTime
      • Arrays of any supported type, ArrayList, byte arrays (which will automatically be Base64 encoded)
      • DataSet and DataTable, but not DataColumns or DataRows
    • Creating a Web Service
      • Choose Add New Item from the context menu of a folder
      • Select Web Service and name the file
      • The asmx file is created in the folder, this file is not modified by you as there can be no user interface
      • Another file, asmx.cs is created in your App_Code folder. This is where your code is written
    • [WebService(Namespace = "Seneca.Ian.Webservices", Description = "Example web service that returns warp server information")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class serverInfo : System.Web.Services.WebService { public serverInfo () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod(Description="This method returns a greeting and the time of day.")] public string whatTime() { System.Net.NetworkInformation.IPGlobalProperties thisServer = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties(); return "Good day mate! - It is " + DateTime.Now.ToLongTimeString() + " at host " + thisServer.HostName + " (domain " + thisServer.DomainName + ")"; } }
    • Web Service Class
      • The new class created derives from the class System.Web.Services.WebService
      • This allows you to use ASP.Net objects such as Application, Session, Server and User
    • Documenting a Web Service
      • Documentation (comments) is extremely important as it tells subscribers how to use your Service
      • WebService declares a namespace, which you choose, and includes a Description for the Service
      • The namespace should include a reference to your server and you, i.e. “Seneca.Ian.Webservices”
      • WebMethod includes a Description for each method and must precede each method
    • Testing Your Service
      • Enter the URL of your service into a browser and it will display the Service information page, if your code is properly constructed –
      • Select “Service Description” and you will see the XML code for the Service
      • Select a Method name and you will see the XML code for the Method when you are working on the server
      • If you are working on the Local Machine you will see a test page, click the test button and you will see the results of a call to the Method
    • Invoking a web service: protected void Page_Load(object sender, EventArgs e) { //The following line is necessary when calling a web service from warp when your account is also on warp ConfigurationManager.AppSettings["WarpIanWebService.serverInfo"] = "http://web1/ian/Services/serverInfo.asmx"; //Instantiate an instance of the web service WarpIanWebService.serverInfo srv = new WarpIanWebService.serverInfo(); //Call the web service method lblResult.Text = srv.whatTime(); }