WEB400 Loose Coupling & Serialization Patterns Clemens Vasters newtelligence AG

Slides:



Advertisements
Similar presentations
Best Practices in Web Service Style, Data Binding and Validation (for use in Data-Centric Applications) David Meredith, Asif Akram, Rob Allan CCLRC Daresbury.
Advertisements

Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
Programming Languages and Paradigms
Web Services Seminar: Service Description Languages
DEV351 ADO.NET Performance Pablo Castro Program Manager – ADO.NET Team Microsoft Corporation.
WEB401 Security Practices for Web Services (Part 2) Keith Ballinger Program Manager XML Messaging Microsoft Corporation.
Achieving Distributed Extensibility and Versioning in XML Dave Orchard W3C Lead BEA Systems.
Apache Axis: A Set of Java Tools for SOAP Web Services.
Peoplesoft: Building and Consuming Web Services
Windows Forms in Visual Studio 2005: An Overview Saurabh Pant Program Manager Microsoft Corporation.
Today’s Agenda 14:30 Communication & Collaboration Platform 14:50 Portals & Document Management 15:10 Enterprise Project Management 15:30 Break 15:50 Business.
1 SOAP Simple Object Access Protocol 大葉大學資工系. 2 Purpose of SOAP Developers need to establish a standard transport and data-exchange framework to achieve.
DAT304 Leveraging XML and HTTP with Sql Server Irwin Dolobowsky Program Manager Webdata Group.
OFC302 Building Smart Document Solutions in Word & Excel Martin Sawicki Lead Program Manager.
OFC 322 Building Office Research Web Services: Exposing Corporate Data Through Office Brian Jones Program Manager Authoring Services Martin Sawicki Lead.
DEV334 Creating Application Starting Points & Sharing Best Practices with Enterprise Templates Marc Gusmano Director of Emerging Technologies The Information.
OFC304 Excel 2003 Overview: XML Support Joseph Chirilov Program Manager.
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
DEV290 Building Office Solutions with Visual Studio Eric Carter Lead Developer Developer Platform & Evangelism Microsoft Corporation.
DAT305 Boost Your Data-Driven Application Development Using SQL Server Centric.NET Code Generator Pascal Belaud Microsoft France.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 2 Lecturer.
OFC 303 Advanced Word XML: Customer-Defined Schemas Brian Jones Program Manager Authoring Services.
DEV325 Deploying Visual Studio.NET Applications Billy Hollis Author / Consultant.
OFC 308 Advanced Word XML: The WordML Schema and Bringing Everything Together Brian Jones Program Manager Authoring Services.
WEB390 Ouch! Common XML Web services headaches (and possible solutions) Christian Weyer Microsoft MSDN Regional Director
OFC 307 Office 2003 Solution Case Studies Ray Stephenson Smart Client Technical Evangelist
XML Web Services Architecture Siddharth Ruchandani CS 6362 – SW Architecture & Design Summer /11/05.
Web 310 XML Schema : What You Need to Know and Why Yasser Shohoud Program Manager XML Messaging Microsoft Corporation.
DEV337 Modeling Distributed Enterprise Applications Using UML in Visual Studio.NET David Keogh Program Manager Visual Studio Enterprise Tools.
FIMS v1.1 Version numbers in schema Richard Cartwright Quantel July 2013.
10 – 12 APRIL 2005 Riyadh, Saudi Arabia. Visual Studio 2005 : New Features for the Web Services Developer Malek Kemmou CEO Arrabeta Consulting Microsoft.
DEV333 Instrumenting Applications for Manageability with the Enterprise Instrumentation Framework David Keogh Program Manager Visual Studio Enterprise.
Copyright© 2005 Oracle Corp.1 SQL/XML Jim Melton USA: Oracle Corp. JTC1 SC32N1632.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
Tutorial 13 Validating Documents with Schemas
COM326: Web Services for XML Programmers Doug Purdy Lead Program Manager Connected Systems Division.
OFC291 Microsoft® Office Word XML (part 1 of 3): Introduction Martin Sawicki Lead Program Manager.
DEV330 Visual Studio.NET IDE Tips and Tricks Billy Hollis Author / consultant.
Dev 328.NET & J2EE Strategies for Interoperability David Aiken Lead Enterprise Architect.
INT-9: Implementing ESB Processes with OpenEdge ® and Sonic ™ David Cleary Principal Software Engineer.
EBIZ327 InfoPath and BizTalk Server 2004 Scott Woodgate Jupiter Product Planner.
Web Services Error Handling and Debugging. Agenda Simple SOAP faults Advanced SOAP faults SOAP headers and faults Error handling From a Service Perspective.
ASP.NET Web Services.  A unit of managed code installed under IIS that can be remotely invoked using HTTP.
Connect with life Vedant Kulshreshtha Technology Solutions Professional – SharePoint | Microsoft India
David Orchard W3C Lead BEA Systems Web service and XML Extensibility and Versioning.
MSG331 Exchange Server 2000/2003 Software Development Kit Susan Hill Lead Programmer Writer Microsoft Corporation.
DEV395 No Touch Deployment for Windows Forms Jamie Cool Program Manager.NET Client Microsoft Corporation.
Web services. Introduction to WSDL. February 23, 2006.
EBIZ302 Jupiter Business Process Automation and Web Services David Fong Program Manager.
DEV332 Programming for the Middle Tier in Visual Basic.NET Billy Hollis Author / Consultant.
.NET Mobile Application Development XML Web Services.
DAT 405 Extreme SqlXml Irwin Dolobowsky Program Manager – SqlXml Microsoft Corporation.
Christian Weyer thinktecture.
OFC311 Developing Microsoft Office InfoPath 2003 Solutions: Technical Drilldown Part 1 Tudor Toma Group Program Manager Office Microsoft Corporation.
PIX/PDQ – Today and Tomorrow Vassil Peytchev Epic.
OFC320 Building EPM Solutions with Microsoft Project Server Ted Dinklocker Program Manager Microsoft Corp.
Application Integration Framework (AIF) Dean Wierman Lead Program Manager Microsoft Corporation.
Introduction to Web Services Srinath Vasireddy Support Professional Developer Support Microsoft Corporation.
DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems
Sabri Kızanlık Ural Emekçi
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
Visual Studio Tools for Office 2005
Searching Business Data with MOSS 2007 Enterprise Search
WCF (Indigo): Under the Hood of the Channel Layer
Searching Business Data with MOSS 2007 Enterprise Search
Working with different JavaScript frameworks and libraries
InterOp Technical Notes
Windows Forms in Visual Studio 2005: An in-depth look at key features
Windows Forms in Visual Studio 2005: An Overview
Contexualized Data In Document Authoring
Presentation transcript:

WEB400 Loose Coupling & Serialization Patterns Clemens Vasters newtelligence AG

Agenda Definitions Objectives Development Approaches Designing Messages Enabling resiliency Q&A

Definition: Loose Coupling Macro: Varying implementations J2EE .Net,.Net v1 .Net v1.1, etc. SOA is the solution Micro: Flexible/Resilient implementation Optional data & unions New messages New operations Smart contract & schema design is the solution

Definition: Serialization The transformation of a graph of objects to a stream and back again Roll your own System.Xml.Serialization System.Runtime.Serialization The transformation of a CLR type into an XSD schema and back again Roll your own System.Xml.Serialization

Definition: Pattern “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing the same thing twice.” -- Christopher Alexander

Objectives Learn the best mechanisms to achieve “micro” loose coupling for data Learn how to make messages flexible & resilient to change Learn how loose coupling manifests itself in the programming model Disclaimer: Some of the code/schema has been cut to fit on slides

Development Approaches Two options for developing messages Code first: “I like the CLR” Schema first: “I like XSD” We love both of them Code first is more familiar but implicit Schema first is explicit but less familiar We map from schema  code To achieve loose coupling you must understand XSD – code or schema first

Code First Development The best way to avoid unsupported schema constructs If you can do it in code – it is supported Use the [SoapDocumentMethod] Controls the contract that is emitted Useful settings ParameterStyle=SoapParameterStyle.Bare Use=SoapBindingUse.Literal Examine the induced contract often

Schema First Development Some schemas cannot be mapped We are working on documenting this Develop schema & contract separately Use WSDL import to associate them Do not use “parameters” message part You want “bare” semantics Always, always, always use doc/literal Encoding – what is that?

Schema First Development Use disco.exe to retrieve documents Use wsdl.exe /server to create stub Modify stub to make it all work Strip abstract class & method modifiers Add Location to [WebServiceBinding] Add Binding to [SoapDocumentMethod] Add your implementation This is easier than creating a subclass

Designing Messages Each message part resolves to an element (doc/literal) You have a lot of options with varying degrees of “coupledness” for the element types xsd:anyType aka System.Object xsd:string aka System.Object User-defined types (UDTs hereafter) You must choose wisely…

Object  xsd:anyType Send anything you want If the serializer supports & knows about it Very open – lots of flexibility Very open – shoot yourself in the foot Must negotiate semantics out of band <schema xmlns=" targetNamespace=" </schema> public string AddPerson( [XmlElement(Namespace=" object person) {...}

String  xsd:string Better know as “XML as string” Slightly less open than anyType, but has many of the same issues Just about anything can be represented as a string <schema xmlns=" targetNamespace=" </schema> public string AddPerson( [XmlElement(Namespace=" string person) {...}

User-defined Types (UDTs) Most commonly used Not resilient to change by default </schema> public string AddPerson( [XmlElement(Namespace=" Person person) {...}

UDTs and optional data Elements can be optional Defines must-haves & nice-to-haves </schema>

UDTs and optional data UDT contains xxxSpecified “buddy” member Value determines element presence [XmlType(Namespace=" public class Person { public string name; public string name; public string ssn; public string ssn; public int age; public int age; [XmlIgnore()] [XmlIgnore()] public bool ageSpecified; public bool ageSpecified;}

UDTs and unions XSD supports a choice between elements </schema>

UDTs and unions UDT contains choice “buddy” member [XmlType(Namespace=" public class person { public string name; public string name; [XmlElement("driverslicence", typeof(string))] [XmlElement("driverslicence", typeof(string))] [XmlElement("passportnumber", typeof(string))] [XmlElement("passportnumber", typeof(string))] [XmlElement("ssn", typeof(string))] [XmlElement("ssn", typeof(string))] [XmlChoiceIdentifier("ItemElementName")] [XmlChoiceIdentifier("ItemElementName")] public string Item; public string Item; [XmlIgnore()] [XmlIgnore()] public ItemChoiceType ItemElementName; public ItemChoiceType ItemElementName;}

Designing Messages Code Code

Enabling resiliency Changing without breaking Clients work without recompile Data is not lost on roundtrip Requires forethought There is no magic for this -- yet Most mechanisms for UDTs xsd:anyType & xsd:string don’t need help Namespace versioning is not versioning New namespace != new version New namespace == new elements & types

Element/Attribute wildcards Better know as open content model Substitution with some restrictions Very resilient user-defined type ;-) </schema>

Element/Attribute wildcards Use XmlElement & XmlAttribute as programming model You process the XML directly [XmlType(Namespace=" public class person { [XmlAnyElement()] [XmlAnyElement()] public XmlElement[] Any; public XmlElement[] Any; [XmlAnyAttribute()] [XmlAnyAttribute()] public XmlAttribute[] AnyAttr; public XmlAttribute[] AnyAttr;}

Wildcards and UDTs Need resiliency for your UDT? Wildcards to the rescue <sequence> <any processContents="lax" minOccurs="0" <any processContents="lax" minOccurs="0"maxOccurs="unbounded"/></sequence> </schema>

Wildcards and UDTs Use your fields as you always would Optionally add more data in the future [XmlType(Namespace=" public class person { public string name; public string name; public string ssn; public string ssn; [XmlAnyElement()] [XmlAnyElement()] public XmlElement[] Any; public XmlElement[] Any; [XmlAnyAttribute()] [XmlAnyAttribute()] public XmlAttribute[] AnyAttr; public XmlAttribute[] AnyAttr;}

Processing wildcards A version attribute is useful, especially with wildcards <sequence> <any processContents="lax" minOccurs="0" <any processContents="lax" minOccurs="0" maxOccurs="unbounded" /> </sequence> </schema>

Processing wildcards Switching for proper processing public string AddPerson([XmlElement(Namespace=" Person person) { switch (person.version) { switch (person.version) { case "1.0": case "1.0": return DoAddPersonV1(person); return DoAddPersonV1(person); default: default: return DoAddPersonV2(person); return DoAddPersonV2(person); }}

XmlElement Parameters Code first only Generates an fairly open content model [WebMethod] public void AddPerson(System.Xml.XmlElement person) {...} <schema>

Enabling resiliency Code Code

Summary Think hard about loose coupling If you think it is going to change, it will This is similar to security – you need to design it in SOA & WS enable loose coupling, but they don’t guarantee it There are many tools to achieve this Both code first & schema first are valid Choose which mechanism is right for you

Resources Web sites Newsgroups microsoft.public.dotnet.xml microsoft.public.dotnet.framework.aspnet.we bservices Contacts

Community Resources Most Valuable Professional (MVP) Newsgroups Converse online with Microsoft Newsgroups, including Worldwide User Groups Meet and learn with your peers

evaluations evaluations

© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.