Soa wcf 1.1


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Soa wcf 1.1

  1. 1. Who I amI am Sharada Prasad, having 17+ years of exp. in science and technology.My exp. Includes Tech. training/Product development/Tech. analysis/consulting inIT/CS/Physics/IPR.M.Sc Physics(Elex); M.Tech(CS); Dip (IPR)Sbermola@hotmil.comMobile:981020145370-C, Mig, Sect-100, Noida. Sharad Prasad IT/IPR Consultant
  2. 2. What I will cover• SOA introduction• What is WCF? - Intro. to WCF as SOA platform• Why WCF?- Some reasons for using WCF• How WCF?- Demo for creating, hosting, and calling WCF services Sharad Prasad IT/IPR Consultant
  3. 3. SOA introduction• SOA is an evolved programming model for business.• Evolution of programming – In 60’s: • hll such as COBOL, FORTRAN evolved; Compilers were common tools for programming; JUMP, GOTO kind of statement were common; • Ripple effect in code - as code was highly coupled and least cohesive therefore further evolution was needed. – In 70’s: • Structured programming; C, PaSCaL; code reuse through functions; but functions were tied to data • Still code was coupled and not much cohesive – needed further evolution – In 80’s: • Object orientation; C++, smalltalk, ada; abstraction/inheritance; code was less coupled and more cohesive – In 90’s: • Component based; lib;dll; COM/CORBA; code was less coupled and highly cohesive; • Interoperability was complex – In 2000’: • Service orientation; Web services; XML/SOAP• Most of the known issues { ripple effect, coupling, cohesion, integration} are solved in SOA. – Highly cohesive and least coupled code, which is easily interoperable and discoverable • So, SOA is a business facilitator Sharad Prasad IT/IPR Consultant
  4. 4. SOA as a business facilitator, how?• Loosely coupled code {services}• Contracts {adherence to SLA }• Autonomy {control of BL services encapsulates}• Abstraction { hide BL from service consumers}• Reusability { divide BL into reusable services}• Statelessness {min. retention of info. Specific to an activity }• Discoverability { self-describes so that they can be found and assessed} Sharad Prasad IT/IPR Consultant
  5. 5. SOA meets the computing challenges?• Compute - Processing {IaaS, PaaS, SaaS}• Storage - Memory {IaaS, PaaS, SaaS}• Networking -Communication {IaaS, PaaS, SaaS}• Energy - Power {IaaS, PaaS, SaaS}• Environment - Pollution {IaaS, PaaS, SaaS}• Material - Business {IaaS, PaaS, SaaS}• Humanity - Social {IaaS, PaaS, SaaS} Sharad Prasad IT/IPR Consultant
  6. 6. Some of the SOA platforms• MS Share Point/BizTalk server• Smart SOA & WebSphere• SAP NetWeaver Process Intrergration• Oracle Enterprise Service Bus• TIBCO Active Matrix BusinessWorks• Unify NXJ• ServiceMix• .• .• . Sharad Prasad IT/IPR Consultant
  7. 7. What is WCF?• MS framework for building SOApplication – For building distributed and interoperable apps.• Unifies ASMX, .NET Remoting, and Enterprise services stacks – In a single prog. Model. – Configurable protocol choices, messaging formats, and process allocation, etc.• Service-oriented – Built for service-oriented system design – Simplifies how you approach SOA• Loosly coupled – Every thing is configurable – Not bound to a particular protocol, encoding, or hosting environ• Interoperable – Supports core web services standards – Extensible to Quickly adapt to new protocols and updates• Integration – Integrates with earlier MS stacks • Com, services, msmq Sharad Prasad IT/IPR Consultant
  8. 8. Why to use WCF?• Because,• Services are the core of the SOA and WCF is the easiest way to produce and consume services on MS platform.• By leveraging WCF, developer can focus on their application rather than on communication protocol• It is a classic case of tech. encapsulation and tooling• Developers are more productive if their tools encapsulates (but not hide) tech. jobs wherever possible, and WCF combined with VS does the same Sharad Prasad IT/IPR Consultant
  9. 9. How to use WCF?• Code Walkthrough – { • Let say you have your legacy code (BL)- BLTDSCalc as a dll • Wrap the existing BL (BLTDSCalc.dll) in a SOA service (class) • Add some more business logic the SOA class let say - BLGenerateTDSCertificate • Define service contracts for both Methods • Host the service – Contract, behavior, binding, addressing, channels, messaging, formatting, security all in code – Above things can be divided in code (c#) and configuration (xml) in separate files • Use the services – Discovery to get the contract and configuration using ASR » Metadata exchange should be enabled – Use svcutil.exe to discover the services. – } Sharad Prasad IT/IPR Consultant
  10. 10. Code//this is our old business logic - a class dllnamespace TDSCalc{ public class CTDSCalc { //Our old business logic to calculate TDS public double MTDSCalc(double income) { //10% of the income is deducted as TDS return income * 10 / 100; } }} Sharad Prasad IT/IPR Consultant
  11. 11. // we want to move to cloud and adapt to public class TDSService : ITDSService SOA we will use our legacy logic {// (TDSCalc) and add more services CTDSCalc objTDS = new CTDSCalc();// and will use MS Platform for every thing public double GetTDS(double income) { //using our existing serivesusing TDSCalc; return objTDS.MTDSCalc(income);using System.ServiceModel; }namespace SOAClasss }{ public class TDSCertService : [ServiceContract] ITDSCertService public interface ITDSService { { public string GetCertificate(string [OperationContract] name) double GetTDS(double income); { //using our existing serives } return "this is the tds certicate oftt" + name + "tt for year"; [ServiceContract] } public interface ITDSCertService } { } [OperationContract] string GetCertificate(string pr_name); } Sharad Prasad IT/IPR Consultant
  12. 12. // service hostusing System.ServiceModel;using System.ServiceModel.Description;using System;namespace Host{ class Program { static void Main(string[] args) { ServiceHost tdsCalcHost = new ServiceHost(typeof(SOAClasss.TDSService), new Uri("http://localhost/8080")); ServiceHost certHost = new ServiceHost(typeof(SOAClasss.TDSCertService), new Uri("http://localhost/8080/sd/sd")); tdsCalcHost.AddServiceEndpoint(typeof(SOAClasss.ITDSService), new BasicHttpBinding(), "mex"); certHost.AddServiceEndpoint(typeof(SOAClasss.ITDSCertService), new BasicHttpBinding(), "mex"); ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); behavior.HttpGetEnabled = true; tdsCalcHost.Description.Behaviors.Add(behavior); certHost.Description.Behaviors.Add(behavior); certHost.Open(); tdsCalcHost.Open(); Console.Write("service runningn press enter to endn"); Console.ReadLine(); }}} Sharad Prasad IT/IPR Consultant
  13. 13. // service consumerusing System;namespace ServiceConsumer{ class Program { static void Main(string[] args) { // TDS and Cert are two service references TDS.TDSServiceClient tdsproxy = new TDS.TDSServiceClient(); Console.WriteLine("Pl. enter the income"); Console.WriteLine("tds is: {0}", tdsproxy.GetTDS(double.Parse(Console.ReadLine()))); Cert.TDSCertServiceClient certproxy = new Cert.TDSCertServiceClient(); Console.WriteLine("Pl. enter the emp. name for which cert. is needed"); Console.WriteLine( certproxy.GetCertificate(Console.ReadLine())); Console.ReadLine(); } }} Sharad Prasad IT/IPR Consultant
  14. 14. Thank you • QuestionsSharad Prasad IT/IPRConsultant