Session6 : SOA Programming Models Dr. Nipat Jongsawat
หัวข้อนำเสนอ ทบทวน SOA การพัฒนาโปรแกรมใน SOA Web 2.0 & Mashups WCF : Windows Communication Foundation SCA : Service Component Architecture Web 2.0 & Mashups Dr. Nipat Jongsawat
Service-Oriented Architecture เป็นเรื่องของแนวคิด การออกแบบ เพื่อให้ระบบ รองรับ การเปลี่ยนแปลง (interface / implementation) ความหลากหลาย (language, access method) ง่ายต่อ การพัฒนาบริการใหม่ การประกอบบริการที่มีอยู่ Dr. Nipat Jongsawat
จากอดีตถึงปัจจุบัน XML WS Web LAN Internet SOA 1970 1980 1990 2000 Distributed Component Architecture Service-Oriented Architecture Monolithic Architecture Client-Server Architecture Number of tiers 1 2 n Technology Enabler Prog. Lang. (Cobol...) Data Access (ODBC...) Dist. Prog. (CORBA, RMI, COM,...) Web Service Std. (XML, SOAP Level of Interop. Intra-app. Cross Clients Cross App. Intra Enterprise Cross App. Cross Enterprise Common Elements Same physical node, technology, progam Same technology Same Comm.& messaging std. Dr. Nipat Jongsawat
การเปลี่ยนแนวคิดเป็นแบบบริการ From To Connections = cost Function oriented Build to last Prolonged development Connections = value Process oriented Build for change Incrementally deployed Application silos Tightly coupled Object oriented Homogeneous Orchestrated solutions Loosely coupled Message oriented Heterogenous Dr. Nipat Jongsawat
Tightly Coupled Objects Loosely Coupled Services เรา เขา Programming Language Agreements Database Database Operating System Object Model Operating System Application Contract เรา เขา Programming Language Programming Language Agreements Database Database Object Model Object Model Contract Operating System Operating System Application Application Dr. Nipat Jongsawat
เรียกใช้บริการอย่างไร Loose Coupling ผู้ให้บริการ ผู้รับบริการ ออกแบบขั้นตอนทำงาน มีบริการอะไรให้ใช้ สร้างให้เป็นจริง Contract เรียกใช้บริการอย่างไร เปิดให้บริการ บริการอยู่ที่ใด เผยแพร่บริการ Dr. Nipat Jongsawat
แนวคิดเชิงบริการ Applications composed of Operational Requirements enforce State manage governed by Policies Services Contracts bound by have Messages exchange Message Exchange Pattern describe define structure of is a set of contain Schemas Dr. Nipat Jongsawat
หลัก 4 ประการของแนวคิดเชิงบริการ Boundaries are explicit Services are autonomous Share schema & contract, not class Compatibility based on policy Dr. Nipat Jongsawat
ลักษณะของเซอร์วิซ Message Oriented Loosely Coupled Course Grained Contract Based Sync and Async Invokeable Orchestratable Reusable And Ideally Interoperable Dr. Nipat Jongsawat
การสื่อสารระหว่างเซอร์วิซ Service การสื่อสารระหว่างเซอร์วิซ Sign Serialize Message Processing Infrastructure Reliable messaging Service Encrypt Deserialize Authorize Message Processing Infrastructure Validate Audit Log Authenticate Dr. Nipat Jongsawat
Services : Objects การพัฒนาระบบ OO จัดการ network apps ใช้ความเชี่ยวชาญเดิม การพัฒนาระบบ OO จัดการ network apps การ deploy service : host ที่เครื่องเรา object : ส่งให้เครื่องเขา language constructs language libraries object models distributed objects service models Dr. Nipat Jongsawat
แต่ก่อน นักพัฒนามีภาระมาก ต้องตัดสินใจเยอะ ตัวโปรแกรมผสมผสาน J2EE : RMI, JAX-RPC, EJB, JMS, ... .NET : Remoting, ASMX/WSE, DCOM, MSMQ, ... APIs มีมากมาย เปลี่ยนบ่อย และลึกทางเทคนิค ตัวโปรแกรมผสมผสาน business logic service communication Dr. Nipat Jongsawat
ปัจจุบัน มาตรฐานเข้ารูป เครื่องมือเข้าร่าง หลายฝ่ายร่วมมือ ไม่ยึดติด เครื่องมือเข้าร่าง ใช้ง่าย นักพัฒนาสนใจเฉพาะ core business logic ผลักเรื่อง communication, transaction, deployment, policy ไปจัดการที่ส่วนกลาง Dr. Nipat Jongsawat
หัวข้อนำเสนอ ทบทวน SOA การพัฒนาโปรแกรมใน SOA Web 2.0 & Mashups WCF : Windows Communication Foundation SCA : Service Component Architecture Web 2.0 & Mashups Dr. Nipat Jongsawat
.NET Framework 3.0 http://msdn.microsoft.com Dr. Nipat Jongsawat
Services, Workflow, BizTalk WCF WF API for building secure, reliable interoperable services Tools and engine for building workflow-enable apps Application to application and B2B integration Connects multiple services built with WCF Adapters to multiple products like SAP and MQSeries Business activity monitoring Vertical solutions and industry accelerators Message transformation services Enterprise single sign-on End-to-end health and activity tracking And more… Dr. Nipat Jongsawat
public class MsmqTest { [STAThread] static void Main(string[] args) { string queuePath = @".\private$\TSS_MsmqTest"; MessageQueue messageQueue; if (MessageQueue.Exists(queuePath)) messageQueue = new MessageQueue(queuePath); else messageQueue = MessageQueue.Create(queuePath); messageQueue.Send("Hello World!"); ... } public class hello : MarshalByRefObject { public String HelloWorld() { return "Hello World"; } public class hello { [WebMethod] public string HelloWorld() { return "Hello World"; } Dr. Nipat Jongsawat
WCF : Unifying Communication .NET Framework 2.0 Applications ASMX & WSE .NET Remoting Enterprise Services System. Messaging API MSMQ SOAP & WS-* Remoting binary DCOM Protocol Applications .NET Framework 3.0 Windows Communication Foundation API Others SOAP & WS-* WCF binary protocol MSMQ Protocol Dr. Nipat Jongsawat
hosted in IIS, WAS, self-host, WCF Service Endpoints S E R V I C E NETWORK Endpoint Endpoint Endpoint Metadata CLIENT hosted in IIS, WAS, self-host, Windows service Endpoint Dr. Nipat Jongsawat
Service Endpoints WCF Service :โปรแกรมที่เผยแพร่ endpoints ของมัน Address : service อยู่ทีไหน (where) Binding : ติดต่อกันอย่างไร (how) Contract : ให้บริการอะไร (what) ลดภาระของผู้พัฒนาเซอร์วิส สนใจเฉพาะ business function ไม่ต้องพะวงเรื่องวิธีการติดต่อกับเครือข่าย Dr. Nipat Jongsawat
WCF : Service Implementation (C#) [ServiceContract] class HelloService { [OperationContract] string sayHello() return ("Hello"); } Dr. Nipat Jongsawat
Hosting Service http://localhost/hello?wsdl class program { static void Main(string[] args) { Uri base = new Uri("http://localhost/hello"); ServiceHost hs = new ServiceHost( typeof(HelloService), base); hs.AddServiceEndpoint(typeof(HelloService), new BasicHttpBinding(), "http://localhost/hello/svc0"); hs.AddServiceEndpoint(typeof(HelloService), new NetTcpBinding(), "net.tcp://localhost/hello/svc1"); hs.Open(); Console.WriteLine("Service is ready."); Console.ReadKey(); hs.Close(); } http://localhost/hello?wsdl Dr. Nipat Jongsawat
http://localhost/hello?wsdl Dr. Nipat Jongsawat
WCF : Service Client (VB.NET) Dr. Nipat Jongsawat
WCF : Service Client (VB.NET) Dr. Nipat Jongsawat
WCF : Service Client (C#) Dr. Nipat Jongsawat
app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="ServiceMetaBehavior"> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="ServiceMetaBehavior" name="ConsoleApplication1.HelloService"> <endpoint address="http://localhost/hello" binding="basicHttpBinding" contract="ConsoleApplication1.HelloService" /> <endpoint address="http://localhost/hello/mex" binding="mexHttpBinding" contract="IMetadataExchange" /> ... Dr. Nipat Jongsawat
WCF : Bindings Name Transport Encoding Security BasicHttpBinding HTTP XML WS-I Basic Profile 1.1 WSHttpBinding HTTP XML Msg. security, reliable session,... NetTcpBinding TCP binary trans security, reliable session,... NetNamedPipeBinding named binary trans security, reliable session,... piped NetMsmqBinding MSMQ binary trans security, queue transaction . . . Dr. Nipat Jongsawat
WCF : Contracts Contracts : ให้ผู้ให้บริการและผู้ใช้บริการร่วมกันรับรู้และเข้าใจ ServiceContract operations a service can perform (WSDL) DataContract format of data passed to and from service (XSD) MessageContract what goes where in a message (SOAP msg) FaultContract errors likely to be produced (SOAP fault) Dr. Nipat Jongsawat
ServiceContract [ServiceContract] public class MyService { [OperationContract] string operation1() { ... } string operation2() { ... } void helper() { ... } } [ServiceContract] public interface IMyService { [OperationContract] string operation1(); string operation2(); } public class MyService : IMyService { string operation1() { ... } string operation2() { ... } void helper() { ... } } Dr. Nipat Jongsawat
DataContract Primitive types have an implicit data contract. public class Person { [DataMember] public string First; public string Mid; public string Last; private int ID; ... } Primitive types have an implicit data contract. [ServiceContract] public interface IPersonService { [OperationContract] Person GetPerson(int personID); } Dr. Nipat Jongsawat
WCF Dr. Nipat Jongsawat
หัวข้อนำเสนอ ทบทวน SOA การพัฒนาโปรแกรมใน SOA Web 2.0 & Mashups WCF : Windows Communication Foundation SCA : Service Component Architecture Web 2.0 & Mashups Dr. Nipat Jongsawat
SCA : Service Component Architecture ข้อกำหนดการสร้าง composite applications ง่ายต่อการพัฒนา การประกอบ และการให้บริการ รองรับหลากหลายภาษาและเทคโนโลยีการพัฒนา POJOs, BPEL, COBOL, C++ … เกิดการร่วมมือของหลากหลายบริษัทชั้นนำ (พ.ย. 2005) BEA, IBM, Oracle, SAP, IONA, Sybase, Interface21, SAP, Progress, Sybase, TIBCO, Siemen, Sun, ... Royalty-free specifications http://www.osoa.org Dr. Nipat Jongsawat
SCA : Assembly Model การประกอบ service ใหม่จาก service เดิม ไม่ขึ้นกับภาษาการโปรแกรม กำหนด service dependencies รองรับการปรับ config ด้วย properties / protocols / qualities of service profiles สามารถปรับ config ได้ทั้งตอน design time และ deployment time Dr. Nipat Jongsawat
SCA : Service Assembly tightly coupled codes (Composites) loosely coupled services (Systems) System SDO Composite A Refe- rence Service Component A B D Composite C Service C Composite B Service Refe- rence Dr. Nipat Jongsawat
SCA : Service Composite Dr. Nipat Jongsawat
Service Reference ใช้กำหนด services ข้างนอกที่เราต้องการ ใช้ binding เพื่อระบุกลไกการสื่อสาร web service, stateless EJBTM JMSTM JCATM ... สามารถปรับเปลี่ยนลักษณะสมบัติด้วย Policy Composite B Service Refe- rence Dr. Nipat Jongsawat
Service Entry Point ใช้กำหนดบริการต่าง ๆ ที่เรามีให้ ใช้ binding เพื่อระบุกลไกการสื่อสาร web service, stateless EJBTM JMSTM JCATM ... สามารถปรับเปลี่ยนลักษณะสมบัติด้วย Policy Composite B Service Refe- rence Dr. Nipat Jongsawat
SCA : Service Implementation รองรับการสร้างตัวบริการได้หลายภาษาการโปรแกรม JavaTM, BPEL, C++, PHP, … ใช้บริการภายนอกได้ด้วย service references ให้บริการโดยกำหนดเป็น interfaces ที่มีลักษณะ remotable, conversational, bi-directional, companion callback interface ระบบรองรับการจัดการ state ให้ Dr. Nipat Jongsawat
Services : local และ remote Remotable Service ใช้อ้างอิงได้ทั้งภายในและภายนอก module การส่ง parameter และ return value เป็นแบบ by-value มีลักษณะแบบ coarse-grained, loosely coupled interface Local Service ใช้อ้างอิงได้ภายใน module เท่านั้น การส่ง parameter และ return value เป็นแบบ by-reference มีลักษณะแบบ fine-grained, tightly coupled interface เป็น remotable service เมื่อเขียน @Remotable กำกับ Java interface Dr. Nipat Jongsawat
SCA Client and Implementation Model ทำให้ง่ายต่อการให้และใช้บริการ ผู้พัฒนาสนใจเฉพาะ business logic ปัจจุบันมีข้อกำหนดของ Java and C++ binding ต่าง ๆ ปรับตั้งได้ขณะทำงาน ปรับเปลี่ยนพฤติกรรมของบริการได้ด้วยการปรับค่าของ properties ต่าง ๆ ของตัวบริการ Dr. Nipat Jongsawat
SCA : Service Implementation package services; import org.osoa.sca.annotations.*; @Remotable public insterface HelloService { String sayHello(); } package services; import org.osoa.sca.annotations.*; @Service(HelloService.class) public class HelloServiceImpl implements HelloService { String sayHello() { return ("Hello"); } Dr. Nipat Jongsawat
SCA : Service Client package clients; import org.osoa.sca.annotations.*; import services.HelloService; public class HelloClient { @Reference private HelloService svc; public static void main(String[] args) { System.out.println( (new HelloClient()).svc.sayHello() ); } Dr. Nipat Jongsawat
อีกสักตัวอย่าง @Remotable public interface B {...} @Service(B.class) public class BImpl implements B { @Reference D dService; C cService; ... } BComp CComp AComposite A D. public interface C {...} @Service(C.class) public class CImpl implements C { ... } Dr. Nipat Jongsawat
SCA : Service Implementation <?xml version="1.0" encoding="ASCII"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="AComposite" > <component name="BComp"> <implementation.java class="services.BImpl"/> <reference name="cService>C</reference> <reference name="dService>D</reference> </component> <component name="CComp"> <implementation.java class="services.CImpl"/> <service name="A"> <interface.java interface="services.A"/> <binding.ws port="http://me.com/A# wsdl.endpoint(A/ASOAP)"/> <reference>BComp</reference> </service> <reference name="D"> <interface.java interface="ext.D"/> <binding.ws port="http://books.com/D# wsdl.endpoint(D/DSOAP)"/> </reference> </composite> SCA : Service Implementation sca.module BComp CComp AComposite A D. Dr. Nipat Jongsawat
SCA : Binding กำกับทุก service entry point และ reference binding.sca, binding.ws, binding.jms, binding.eis <reference name="StockQuoteService"> ... <binding.jms> <connection destinationName="StockQuoteServiceQueue" connectionFactoryName="StockQuoteServiceQCF".../> <operation name="getQuote"> <inDataBinding name="http://databinding.org/Stream"/> </operation> </binding.jms> </reference> Dr. Nipat Jongsawat
Current SCA Implementations IBM WebSphere Application Server v6.1 Oracle Event-Driven Architecture Suite TIBCO ActiveMatrix Service Grid ... Open sources Apache Tuscany Eclipse SOA Tools Platform Dr. Nipat Jongsawat
WebSphere Integration Developer 6.0 Dr. Nipat Jongsawat
Apache Tuscany http://incubator.apache.org/tuscany/ Dr. Nipat Jongsawat
SCA Dr. Nipat Jongsawat
WCF/SCA : ความเหมือน สร้าง service จาก class เขียนหมายเหตุกำกับส่วนต่าง ๆ ของคลาส (attributes ใน .NET หรือ annotation ใน Java) เพื่อนิยามบริการ ใช้ binding กำกับตัวบริการเพื่อระบุกลไลการสื่อสาร (มี pre-defined bindings ซึ่งสามารถปรับเปลี่ยนได้) รองรับข้อกำหนดตาม WS-* Dr. Nipat Jongsawat
WCF/SCA : ความเหมือน รองรับการสื่อสารทั้งแบบ synchronous calls, แบบ one-way และแบบ two-way interactions (ที่เรียกกันว่า duplex contracts หรือ callback interfaces) รองรับการจัดการ session และ state ระหว่างเรียกใช้บริการ ทั้งคู่มี protocol แบบ optimized เฉพาะของตัวเองด้วย Dr. Nipat Jongsawat
WCF/SCA : ความต่าง SCA มีข้อกำหนดการประกอบ components เป็น module โดยระบุ dependencies ระหว่าง components SCA รองรับการสร้าง service-oriented applications ที่พัฒนาด้วยหลากหลายภาษา SCA ทำงานได้บนหลากหลายเทคโนโลยี เช่น EJB, Spring ส่วน WCF นั้นทำงานบน .NET Dr. Nipat Jongsawat
รายละเอียดเพิ่มเติม WCF SCA Apache Tuscany Project http://wcf.netfx3.com SCA http://www.osoa.org Apache Tuscany Project http://incubator.apache.org/tuscany Dr. Nipat Jongsawat
หัวข้อ ทบทวน SOA การพัฒนาโปรแกรมใน SOA Web 2.0 & Mashups WCF : Windows Communication Foundation SCA : Service Component Architecture Web 2.0 & Mashups Dr. Nipat Jongsawat
Web 2.0 : Definition Web 2.0 is the network as platform, spanning all connected devices; Web 2.0 applications are those that make the most of the intrinsic advantages of that platform: delivering software as a continually-updated service that gets better the more people use it, consuming and remixing data from multiple sources, including individual users, while providing their own data and services in a form that allows remixing by others, creating network effects through an "architecture of participation," and going beyond the page metaphor of Web 1.0 to deliver rich user experiences. Tim O'Reilly Dr. Nipat Jongsawat
1.0 vs 2.0 Akamai BitTorrent Britannica Online Wikipedia personal websites domain name speculation screen scraping publishing content management systems directories (taxonomy) stickiness BitTorrent Wikipedia blogging search engine optimization web services participation wikis tagging ("folksonomy") syndication http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html Dr. Nipat Jongsawat
Dr. Nipat Jongsawat
http://www. oreillynet http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html Dr. Nipat Jongsawat
Dr. Nipat Jongsawat
Web 2.0 Services, not packaged software Data as the driving force Architecture of participation The Long Tail Rich user experiences Lightweight programming models The perpetual beta Some rights reserved http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html Dr. Nipat Jongsawat
Dr. Nipat Jongsawat
Mashup Wikipedia : "A mashup is a website or web application that seamlessly combines content from more than one source into an integrated experience." Enterprise Web 2.0 Web 2.0 SOA Mashups Enterprise Mashups Dr. Nipat Jongsawat
Dr. Nipat Jongsawat
Mashup Styles Mashups "mix & match" Client-side mashups presentations data functionalities Client-side mashups Server-side mashups Dr. Nipat Jongsawat
Dr. Nipat Jongsawat
Demo Accessing Web Services from Excel (Microsoft Office Web Services Toolkit) GreaseMonkey : Amazon + CU-Lib (http://www.mundell.org/archives/greasemonkey/) OpenKapow : CourseDesc + books.google (http://www.openkapow.com) ชมภาพยนต์ (http://mediatedcultures.net/ksudigg/) Dr. Nipat Jongsawat
Dr. Nipat Jongsawat
Dr. Nipat Jongsawat
Misc. Mashups vs Composite App Enterprise mashups are dangerous guerilla-style vs. formal engineering Enterprise mashups are dangerous Confidentiality breaches Unauthorized capabilities Dr. Nipat Jongsawat
รายละเอียดเพิ่มเติม http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html http://blogs.zdnet.com/Hinchcliffe http://programmableweb.com Dr. Nipat Jongsawat