Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.monash.edu.au.NET XML Web Services Monash University Semester 1, March 2006.

Similar presentations


Presentation on theme: "Www.monash.edu.au.NET XML Web Services Monash University Semester 1, March 2006."— Presentation transcript:

1 www.monash.edu.au.NET XML Web Services Monash University Semester 1, March 2006

2 www.monash.edu.au 2 Overview Current Business Models What are XML Web Services and why use them How web services are developed using.NET Extensions to Web Services using.NET

3 www.monash.edu.au 3 Business Applications 3-tier Business applications must separate software into 3 tiers Separate the business process from the user interface and data layers User Interface Business Objects Data Layers

4 www.monash.edu.au 4 Extend your business With 3-tier architecture, you restrict your business to your applications With global economy, you want different global companies to use your software Need to provide another tier to your business process Service Oriented Architecture is what can be used to expose your business to the software world

5 www.monash.edu.au 5 Service Oriented Architecture ProviderConsumer Broker PublishSearch Bind/Invoke

6 www.monash.edu.au 6 What are XML Web Services W3C Definition –“… software application identified by a URI, whose interfaces and binding are capable of being defined, described and discovered by XML artefacts and supports direct interactions with other software applications using XML based messages via internet- based protocols.”

7 www.monash.edu.au 7 Distributed Programming Model Client Server Web Services Description Language (WSDL) Server StubClient Proxy SOAP, XML-RPC Transport (HTTP, FTP, IIOP etc.)

8 www.monash.edu.au 8 Why XML Web Services Supports n-tier Application Architecture (Façade Pattern should be used) Provide a web interface to you current business infrastructure Use web protocols and standards to communicate and transfer information Can be used to communicate through firewalls that block other Distributed Programming models

9 www.monash.edu.au 9 Web Service RMI Service DCOM Service Consumer   Firewall Port 80 Web Services and Firewalls

10 www.monash.edu.au 10 Web Services Standards and Protocols Open Web Protocols –HTTP, XML, SOAP etc. Web Services Contracts/Description –WSDL Advertising and Discovery –UDDI, Disco

11 www.monash.edu.au 11 Service Oriented Architecture ProviderConsumer Broker PublishSearch Bind/Invoke Applications UDDI WSDL

12 www.monash.edu.au 12 Business Applications n-tier Web Service Communication

13 www.monash.edu.au 13 ASP.NET XML Web Services Must use an.ASMX file to create or generate a web interfaceMust use an.ASMX file to create or generate a web interface An ASMX file can contain code or point to a DLL using Code behindAn ASMX file can contain code or point to a DLL using Code behind Must inherit from System.Web.Services.WebService or implement System.Web.Services.WebService as a custom attribute of your classMust inherit from System.Web.Services.WebService or implement System.Web.Services.WebService as a custom attribute of your class

14 www.monash.edu.au 14 Demonstration HelloWorldWS Basic Hello World in.NET

15 www.monash.edu.au 15 Create a Web Service in ASP.NET Declaring Web Services –.ASMX file Implementation –.CS file System.Web.Services.WebService public class HelloWorld: System.Web.Services.WebService{[WebMethod] public string Hello () { return “Hello World”; }}

16 www.monash.edu.au 16 Web Method Description - a property which makes a description available to a WSDL fileDescription - a property which makes a description available to a WSDL file MessageName - the method name used when calling a Web MethodMessageName - the method name used when calling a Web Method Enable Session - defines whether a session state is enabledEnable Session - defines whether a session state is enabled TransactionOption - indicates transaction supportTransactionOption - indicates transaction support CacheDuration – defines the length of time the method invocation should be cached forCacheDuration – defines the length of time the method invocation should be cached for

17 www.monash.edu.au 17 Stateless and Statefull services Stateless means a web service losses its state Web services are normally stateless Usually provide access to state information such as databases and XML files.NET Web services are stateless by default More will be covered in Module 8

18 www.monash.edu.au 18 Publishing Web Services Files –Web.Config and Global.asax file –Assemblies and.asmx files IIS structure –Must create a virtual directory –Must ensure that the web service has appropriate permissions to access and modify resources

19 www.monash.edu.au 19 Consuming Web Services Accessing Web Services from IE –Demonstration Proxy class WSDL tool –Generate source file. Need to compile –Default is in C# Visual Studio.NET automates this process by creating wsdl http://localhost/hello/HelloWorld.asmx?wsdl

20 www.monash.edu.au 20 Demonstration A stock service demonstration http://localhost/StockTradingService/StockService.asmx localhost/WapStockClient/Stocks.aspx

21 www.monash.edu.au 21 WS State Management Statement management objects –Application –Session EnabledSession property in WebMethod attribute –To enable Session object.

22 www.monash.edu.au 22 State Management Web Services are stateless Use ASP.NET session state mechanism –Restricted to a logical application –Context in which a user communicates to a server –Functionality >Request identification and classification >Store data across multiple requests >Session events >Release of session data –.NET State Server Process

23 www.monash.edu.au 23 State Management Each request of a Web Service its class instance is instantiated and thrown away when it is no longer used –i.e. each time you call a method the class variable values are not available be the web service has be re-instantiated If data is required to be used between different requests, the ASP.NET built-in session state mechanisms must be used

24 www.monash.edu.au 24 State Management (cont…) Web services have access to the same state management options as other ASP.NET applications such as the Session and Application objects and cookies Data stored in the Session object is available only when the EnableSession property of the WebMethod attribute is set to true. Access to the Application object is automatic however

25 www.monash.edu.au 25 State Management (e.g.) Declaring a Web service method, with the EnableSession property equal to WebMethod attribute to true. [WebMethod(EnableSession=true)] public string YourName(string name) { if(Session["Name"] == null) if(Session["Name"] == null) Session.Add("Name", name); Session.Add("Name", name); return Session["Name"].ToString(); return Session["Name"].ToString();}[WebMethod(EnableSession=true)] public string YourName(string name) { if(Session["Name"] == null) if(Session["Name"] == null) Session.Add("Name", name); Session.Add("Name", name); return Session["Name"].ToString(); return Session["Name"].ToString();} [WebMethod(EnableSession=true)] public string GetName() { if(Session["Name"] == null) if(Session["Name"] == null) return "no name recorded"; return "no name recorded"; else else return Session["Name"].ToString(); return Session["Name"].ToString();}[WebMethod(EnableSession=true)] public string GetName() { if(Session["Name"] == null) if(Session["Name"] == null) return "no name recorded"; return "no name recorded"; else else return Session["Name"].ToString(); return Session["Name"].ToString();}

26 www.monash.edu.au 26 Caching Uses the ASP.NET Caching Model Improves the performance of application by caching messages Parser Assembly Cache Memory Complier Output Cache Key Normal Cached

27 www.monash.edu.au 27 Web Service Execution Model Synchronous –Like any other call to class methods Asynchronous –Split the method into two code blocks >BeginMethodName >EndMethodName –CLR determines if and when operation has finished

28 www.monash.edu.au 28 Asynchronous invocation Exposed in generated proxy class –Begin and End method Begin method –Return IAsyncResult –Parameters >AsyncCallback >Object End method –Return function return type –First parameter is IAsyncResult

29 www.monash.edu.au 29 Demonstration Building an application that supports asynchronous invocation

30 www.monash.edu.au 30 Transaction Support in Web Services Same as COM+ and Microsoft Transaction Server Declarative Transaction TransactionOption property in WebMethod attribute

31 www.monash.edu.au 31 Windows security Client application –NetworkCredential class >Username, password, domain –CredentialCache class –Credentials property in proxy class

32 www.monash.edu.au 32 Web Services Security ASP.NET Security –Windows security, IIS security –Web.config file Customised SOAP-based security –SOAP Header

33 www.monash.edu.au 33 SOAP Header Inherit from SOAPHeader class Declare a public attribute Apply SOAPHeader attribute to WebMethod –MemberName property However, this is.NET specific

34 www.monash.edu.au 34 Global XML Architecture GXA provides uniform way of using XML web services A Microsoft specific initiative to web services Supports new extensions to web services Implemented in.NET using Web Services Enhancements

35 www.monash.edu.au 35 Web Services Enhancements 2.0 Provides additional Web Services capabilities Additional WS specifications –WS-Security –WS-Policy –WS-Trust –WS-Addressing –Etc.

36 www.monash.edu.au 36 WS-Security By OASIS Enhancements to SOAP messaging A general purpose mechanism for secure messaging Support symmetric and public key technologies

37 www.monash.edu.au 37 WSE 2.0 Demo Using Asymmetric Encryption Using digital certificates

38 www.monash.edu.au 38 Web Service Technologies EJB using Tomcat & Sun ONE toolkit BEA Weblogic IBM Web Sphere.NET using ASP.NET and IIS Many more available

39 www.monash.edu.au 39 Communication between systems

40 www.monash.edu.au 40 Conclusion Businesses use web services for interoperability.NET offers web services through ASP.NET ASP.NET provides caching and supports the Global XML architecture through Web Services extensions


Download ppt "Www.monash.edu.au.NET XML Web Services Monash University Semester 1, March 2006."

Similar presentations


Ads by Google