1 / 18

Distribution of functionality Webservice using WCF

Distribution of functionality Webservice using WCF. x. Different technology combined to form WCF. http://wcftutorial.net/Introduction-to-WCF.aspx. ASP.NET - 1 tier distribution. http://msdn.microsoft.com/en-us/library/bb547119.aspx. ASP.NET - 2 tier distribution.

vgary
Download Presentation

Distribution of functionality Webservice using WCF

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Distribution of functionalityWebservice using WCF x

  2. Different technology combined to form WCF. http://wcftutorial.net/Introduction-to-WCF.aspx

  3. ASP.NET - 1 tier distribution http://msdn.microsoft.com/en-us/library/bb547119.aspx

  4. ASP.NET - 2 tier distribution http://msdn.microsoft.com/en-us/library/bb547119.aspx

  5. ASP.NET - n tier distribution http://msdn.microsoft.com/en-us/library/bb547119.aspx

  6. Webservice - SOAP

  7. Server Client stub proxy remoting remoting formatter channel formatter listener Remoting – architectureServer and client are both .NET • General architecture • Proxy, stub, formatting and channel might be changed. Eg is a binary formatting, witch both is supported by TCP og HTTP, more effective than a textbased (XML)

  8. Remoting service - opportunities • Server-activated object (SAO)also called ”Wellknown objects” • Singleton: one and only one serverobject for all clients • Threadproblem for object data • SingleCall: One object per each method call • The most easy solution, but less effective • State might be keept by using files or database • Client-activated object (CAO) • Activated: One object per each client • lifetime problems – Leasing not supported by IIS

  9. Windows Communication Foundation Architecture http://msdn.microsoft.com/en-us/library/ms733128.aspx

  10. Hosting WCF Side-by-Side with ASP.NET http://msdn.microsoft.com/en-us/library/aa702682.aspx

  11. WCF support the 3 state scenarios Possibly also look for other info about these 3 scenarions on http://www.codeproject.com/KB/WCF/WCFInstance.aspx

  12. WCF host & protocol • Wcfmightlike remoting (singleton og singlecall) beintegrated in an asp.net web project and behosted by the IIS (Internet Information Server),wherewcfalsomightgetaccess for the ASP.NET Session, Application objectsect. • Wcfmightalsobeusedwithoutusing the IIS as selfhosted with otherprotocolsthan http. • Wcfalso support eg json and not only soap, witch not is easyusing the older ASP.NET webservices (asmx - technologi)

  13. WCF data protocols WCF might also be configured to communicate by pure XML http://msdn.microsoft.com/en-us/library/bb547119.aspx

  14. WCF setup • Service is defined with a ServiceContract on the interface / classwitchmightbeworking as service-object, and methodsthat must beavailableexternal for clients must bedefined as OperationContract’s • Transport-objects must bedefined as DataContract and field/propertywitchmightbetransported as data as DataMember’s.

  15. Interface with the contract Normally you will define the contract on an interface but can also define this in the class, if you do not want an interface using System.ServiceModel.Web; // contains ServiceContract and OperationContract classes ……….. namespace MyNamespace { [ServiceContract] // Attribut on interfacet public interface IService1 { [OperationContract] // Attribut on methods witch should be avaible by the service (on proxy) string GetData(int value); If you want to use session on service in a WcfServiceApplication (can not be used on ASP.NET - website under ISS) must ServiceContract'en added parameters and it looks like this : [ServiceContract(SessionMode = SessionMode.Required)]

  16. Implementation of class for the contract usingSystem.ServiceModel; ………. namespaceMyNameSpace { //Default is creattion of a new service-object per eachcall, but it mightbe changed //[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] // Default //[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] // Remember to threadsafe //[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] //DemandwsHttpBinding public class Service1 : IService1 { public stringGetData(intvalue) { return string.Format("You entered: {0} <{1}>", value + count, s); } Connected markeup Service1.svc file, witch is giving the binding to service1: <%@ ServiceHost Language="C#" Debug="true" Service=“MyNameSpace.Service1" CodeBehind="Service1.svc.cs" %> Remark: PerSession på Wwbserver(IIS) demandwsHttpBindingwitchdemandadjusting in web.configThe .SVC file couldalsobereplaced by setting up endpoint information in web.config

  17. Data transport objects (DTO) If transferring complex objects (not simple types, string and array) then these will be serialized - this should be done using a DataContract - previously you could use [Serializable] - on Web service would only be transferred public fields and public property , corresponding to an XML serialization. using System.Runtime.Serialization; [DataContract] // class could be serialized public class CompositeType { [DataMember] // field shoud be included when serialized bool _boolValue = true; string _stringValue = "Hello "; [DataMember] // property value should be included as data when serialized public int OneInt {private get; set;}

  18. Data transport objecter (DTO) DataContract and DataMember When using these you might yourself include a referece to get the dll part of project

More Related