Download presentation
Presentation is loading. Please wait.
Published byJason Woods Modified over 9 years ago
1
.NET Mobile Application Development XML Web Services
2
Introduction In the previous session we examined Remote Procedure Call as a mechanism for allowing distributed software components to interact across the network In this session we will examine >XML Web services, a simple form of cross-platform RPC >Creating and consuming Web services in.NET
3
XML Web Services Web services >provide a simple form of cross-platform RPC >are objects hosted by Web server >enable interaction via textual XML messages >support use of user-defined types as arguments / return values >are not designed to be called by end users, only by other applications Web services do not >offer a user interface >run continuously - objects created on demand (i.e. single call semantics) >preserve state across calls – stateless components
4
Web Service Fundamentals Web services are based on open standards XML >All interactions are textual messages Web Services Description Language (WSDL) >XML description of Web service interface >Used by consumers to create proxies Simple Object Access Protocol (SOAP) >XML encoding of data types >Used to serialize arguments and return values >Operates over http protocol Web services are supported by many environments >e.g. Java,.NET, COM, etc
5
Web Service Architecture Client uses WSDL to create proxy during development At runtime, proxy used to interact with Web service Proxy handles marshalling and other low-level details
6
Web Services and Serialization Arguments / return values for Web services are serialized to XML .NET Web services use the XMLSerializer class to perform serialization. This class >provides simpler form of serialization than the full SOAP serialization used by.NET Remoting >only serializes public data members and simple-user defined types >does not transfer code with the serialized instance receiver cannot call methods, properties or events of this type
7
Supported Data Types in.NET Web Services Basic types >bools, ints, floats, strings, dates & times Enumerations Arrays and simple collections >of supported types only User-defined types >public data members and readable properties based on public members only DataSet instances XMLNode instances >portions of XML documents
8
Creating a.NET Web Service Create dedicated IIS virtual directory >Use VS ASP.NET Web Service project type Create C# class to implement service >Each remotely callable method must be tagged with [WebMethod] attribute >Simplest Web service is collection of stateless methods >Compiled to.asmx class Create WSDL Deploy WSDL and.asmx files to Web server Everything in grey is done automatically by Visual Studio
9
Consuming a Web Service Find Web service using known URL, discovery document or UDDI registry >‘Add Web Reference’ in Visual Studio Retrieve WSDL for Web service >Used to create proxy before compilation >What happens if Web service interface changes? Implement client logic and use proxy to invoke Web service Everything in grey is done automatically by Visual Studio
10
Web Service Proxies Created in.NET as hidden source code class in Web References folder Contains >synchronous and asynchronous versions of Web methods defined by Web service >simple definitions of other types (public data members only) used, if needed Bound to a specific Web service URL >Customizing the hidden source class constructor allows proxies to Web services of the same type to be constructed at runtime
11
Asynchronous Interaction Web services offer two forms of asynchronous method invocation One-Way Web service methods >Tagged with [OneWay] attribute >Call to one-way method via proxy returns immediately (fire-and-forget) >Return values are not possible; void methods only Asynchronous method invocation >Standard feature of.NET >Simplified in Web services; generated proxy has asynchronous versions of all calls >Uses callback method to obtain return values
12
Example: Creating a.NET Web Service Simple Web service to calculate cumulative interest Single Web method required >Accepts two parameters Amount of loan (int) Length of loan (int) >Returns LoanDetails instance which contains the total amount payable Definition of LoanDetails type does not exist at client before proxy is built Interest rate on loan is fixed and known only to Web service
13
Example: Consuming a Web Service Simple Windows application for entering loan amount and period Uses LoanCalculator Web service to retrieve LoanDetails instance with total loan amount Note difference in members/properties in the LoanDetails type created by the proxy and that in the Web service.
14
In this session we have discussed >XML Web services >Creating and using Web services in.NET In the next session we will consider messaging and communication from mobile devices Summary
15
Reading and Resources Reading MacDonald, Microsoft.NET Distributed Applications: Integrating XML Web Services and.NET Remoting, Microsoft Press, 2003 Chapter 5, pp139 – 174 Resources Web Services Developer Centre >http://msdn.microsoft.com/webservices/http://msdn.microsoft.com/webservices/ Designing.NET Web Services >http://msdn.microsoft.com/webservices/building/frameworkandstudio/designing/default.asp xhttp://msdn.microsoft.com/webservices/building/frameworkandstudio/designing/default.asp x Indigo, the next generation of Web Services in Windows Longhorn >http://msdn.microsoft.com/webservices/building/indigo/default.aspxhttp://msdn.microsoft.com/webservices/building/indigo/default.aspx
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.