web307 web services deployment, configuration & versioning richard turner program manager xml...
TRANSCRIPT
WEB307
Web Services Deployment, Configuration & Versioning
Richard TurnerProgram ManagerXML Enterprise ServicesMicrosoft Corporation
Contents
DeploymentXCOPYMSIThird Party ToolsSDC Build & Deployment ToolPublishing Web Services
Configuration.NET ConfigurationConfig FilesDBMS Config
Versioning.NET VersioningWeb Services VersioningRemoting VersioningDatabase Versioning
Deployment
Distribution of components, content and configuration
Essential to keep as an atomic unitAutomatic deployment is nirvana
Several tools / techniques:XCOPYMSI Installer
Build-in Visual Studio.NET Setup ProjectsThird Party tools
Domain specific toolsRemember to test!
XCOPY Deployment
Can be very quick and very simple
May require scriptingTo configure environment
To create & configure platform, eg:VRoots
Folders
Mailboxes
IIS doesn’t need to be restarted Great for automated deployments
MSI Based Installations
Microsoft Installer technology built into Windows
Provides transacted, atomic deployment and configuration of applications
Corrupted installations can be repaired
Broad industry supportInstallation Builders
Deployment Tools
VS.NET Setup Projects
Visual Studio.NET includes several setup projects:
Setup
Web Setup
Merge Module
CAB
The Wizard will guide you
Great for Quick ‘n’ dirty deployments
Moderate levels of control
Third Party Installer Tools
Third party tools are an important consideration
Packaging & Web DeploymentInstallShield
Wise
ZeroG
Many tools provide powerful featuresScriptable & customizable engine
Visual Studio integration
Cross-platform support
Deployment Tools
Content Management & DeliveryMicrosoft Content Management Server
Vignette
Interwoven
DeploymentMicrosoft SMS
Tivoli
Zero G
Altiris
ManageSoft
SDC Build & Deployment Tool
Developed by Microsoft’s Solution Development Center
Used to build significant real-world solutionsCombines 3 services: Build, Packaging and DeploymentBuild:
Controlled through an XML makefilePowerful and flexible – can build Windows apps, Websites, WebServices, etc.
PackagingAll deployable resources packaged into MSI files
SDC Build & Deployment Tool
DeploymentDeployment engine instantiated by MSI installer and is driven by XML deployment fileSupports creation of:
IIS VRootsFolders & ACL’sSQL DatabasesBizTalk provisioningEnterprise Services / COM+ ComponentsWindows ServicesEtc…
Support for more technologies on the way
SDC Build & Deployment Tool
Tool available publicly at:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=2cb20e79-d706-4706-9ea0-26188257ee7d
Full source code available for your own customizationNo formal supportMay need modifications for your needs or environment
Publishing Web Services
Who will use your Web Service?
How and where will they find it?
UDDI, WS_Inspection and WSDL can help!Defined by Microsoft, IBM, Ariba and others
Submitted to standards bodies for ratification
Gaining broad industry support
WSDL likely to become the Web Services equivalent of IDL + + + + + + + + !!!+ + + + + + + + !!!
Web Service Discovery
UDDIFederated Web Services meta-data directoryPowerful search & query capabilitiesIncluded in Windows 2003 ServerAvailable on many platforms from a number of vendors
WSDLDetailed type, interface and protocol spec’s for Web ServicesInherent within .NET
WS_INSPECTIONEnumerate Web Services within a machine / environmentRequires implementation at present …
Database Deployment
Many ways to deploy DatabasesDepends on facilities offered by DBMS’ vendor
Microsoft SQL Server has a comprehensive range of options:
Write your own script in TSQL or SQL-DMO
Generate DB Script from existing DB
Database export & import wizards (schema + data)
Replication
Backup and restore elsewhere
Detach files and re-attach elsewhere
Explore your DBMS’ facilities
Deployment Process
Reliable, repeatable deployment can be hard to achieve!Plan your deployment story in detailTest several times before final deploymentTest again and again and again …Test on different hardware & environmentsEffective testing is exponentially more important when upgrading a running system!Plan for when things go wrong
Because they usually do!!!!!Practice makes perfect!
Configuration
Considering:.NET, ASPX config
Platform
Data tier
.NET Configuration
.NET is configured through XML configuration files:machine.config
holds machine-wide config settingsweb.config
holds config information for ASP.NET web sites and web services
app.exe.configConfiguration for .NET applications
Config files are manipulated through:Manual intervention Script / codeTools
machine.config
Found in:%windir%\Microsoft.NET\Framework\v1.x.yyyy\config\machine.config
Provides a great deal of control over .NET & ASP.NET engine, including:
CPU affinity
Worker process & thread characteristics
Request limits
Process user identity
Web Services configured via XML web.config file:
<?xml version="1.0"?><configuration>
<system.web><compilation … /><customErrors … /><authentication … /><authorization … /><trace … /><sessionState … /><globalization … />
</system.web></configuration>
Web Service Configuration
HeaderHeader
FooterFooter
Configuration Configuration SectionsSections(small selection)(small selection)
Configuring for Availability
What happens when your app crashes, hangs or eats the whole machine?
For IIS5.x, consider the <processModel> element in machine.config
Configuring Memory limits, thread limits etc. can help your applications!
For IIS6, use the IIS configuration console<processModel> is ignored!
Configuring for Security
How do you secure your Web Service?
Web.config contains key security settingsAuthentication methods including:
Anonymous, Basic, Windows, Certificate, Kerberos, Forms
Authorization for Users & Roles, eg:<authorization> <allow verb="GET" users="*" /> <allow verb="POST" users="Mary" /> <deny verb="POST" users="*" /> </authorization>
Extending Configuration
Consider storing app specific config in custom sections:<appSettings> <add key=“dbConnStr" value=“database=Sales;user=…"/></appSettings>
Create a Configuration Section Handler which implements the following interface:namespace System.Web.Configuration { public interface IConfigurationSectionHandler { public Object Create(Object parent,
Object input,XmlNode node);
}}
Data Tier Configuration
Most DBMS’ have powerful configuration capabilities
Microsoft SQL Server configurable through: 1170 system Stored Procedures
SQL Distributed Management Objects (SQL-DMO)
Consider implementing a config tool or script for your project:
Repeatability is key!
Versioning
Goodbye “DLL Hell”!
Versioning is inherent to .NETAssembly Versioning
Remoting Versioning
No technological versioning story for Web Services!
But there are still ways ;)
Requires careful planningBuild versioning into your designs
Make careful decisions around encoding etc.
.NET Assembly Versioning
.NET versions at the Assembly levelMajor.minor.build.revision
Eg: .NET Frameworks 1.1 = 1.1.4322.573
All assemblies are version checked by the CLR loader if strongly named
Versions can be coerced through config files:<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly><assemblyIdentity name="MarineCtrl"
publicKeyToken="9335a2124541cfb9" /> <bindingRedirect oldVersion=“1.1.34.2"
newVersion=“1.7.98.5" /> </dependentAssembly>
</assemblyBinding>
File & Assembly Versioning
Files and assemblies can be versioned independentlyThe <AssemblyVersion> attribute defines the assembly’s version that CLR binds againstThe <AssemblyFileVersion> updates the file version stringWhen should I update version numbers?
For pre-ship builds: Keep assembly versions the same between builds, but update the file version infoFor shipped product: Increment the build only if your new Assembly changes it’s semantics or risks breaking existing code. Otherwise, just rev the revision
Only update major or minor when big changes occurUpdate your version numbers during your build process
Try to avoid the “1.2.*” wildcard mechanism … can introduce uncertainty!
Web Service Versioning
Web Services do not support full .NET versioning mechanisms externally
Since versioning is not a Web Service technology
Key goal is to extend a type over time without breaking existing consumers
Several Web Service versioning techniques
Namespace Versioning
Implemented through URI’sDate Encoded:http://foo.org/2003/05/23/Invoice/Invoice.asmxVersion Encoded:http://foo.org/v2.0.4822.2/Invoice/Invoice.asmx
Familiar to anyone who navigates the W3C spec’sQuick, simple and dirty versioning strategyBut … plagued by problems:
Each new “version” invisible to existing clients without redirectionEven with redirection, existing clients validate messages against XSD which is now differentNew namespace != new versionNew namespace == new elements & types
Recommend Namespace Versioning not be used … unless you can accept breaking downlevel clients
So what do I do?
Bear with us we’re working on solving this in the future ;)
Until then, there are several versioning techniques:
Loosely typed fields
Optional elements
User parsed datatypes
Essentially, consider making your web services version-flexible!
Requires that you learn to lve XSD!
Loosely Typed Fields
Specify methods accepting parameters of “object” typepublic string AddSale(
[XmlElement(Namespace="http://sales")]object sale) {...}
Map these properties to XSD elements<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://sales"><element name="sale" type="anyType"/>
</schema>
Up to the application to then parse the data accordinglyThe parameters’ data is not implicitly validated against schema
Optional Elements
Useful when extending existing typesDoes not break existing consumersInherently validated against XSDEg, V1:<schema targetNamespace="http://sales" xmlns="..." > <element name=“sale"> <complexType name=“sale"> <sequence>
<element name=“customerName" type="string"/> </sequence> </complexType> </element></schema>
[XmlType(Namespace="http://people")]public class Sale {
public string customerName;}
Optional Elements (cont…)
V2:<schema targetNamespace="http://sales" xmlns="..." > <element name=“sale"> <complexType name=“sale"> <sequence>
<element name=“customerName" type="string"/><element name=“itemCount" type="int" minOccurs="0"/>
</sequence> </complexType> </element></schema>
[XmlType(Namespace="http://people")]public class Person {
public string customerName;public int itemCount;
[XmlIgnore()]public bool itemCountSpecified;
}
V2 aware code sets V2 aware code sets this …this …
… … and the serializer and the serializer writes thiswrites this
Serializer sees that this field Serializer sees that this field exists and sets this to trueexists and sets this to true
V2 aware code reads this V2 aware code reads this and acts accordinglyand acts accordingly
Open Content Types
Consider Open Content Model for types that are highly dynamic in structure
<schema targetNamespace="http://people" xmlns="..."> <element name="person"> <complexType> <xs:sequence>
<xs:any processContents="lax" maxOccurs="unbounded“ minOccurs=“0” />
</xs:sequence> <xs:anyAttribute processContents="lax"/> <attribute name="version" type="string" use="required"/>
</complexType> </element></schema>
Can still specify structured elements within such structuresUse property bags for open extensibility
Open Content Usage
When deserialized, elements that do not exist as fields in the object are collected into an array which can be processed accordingly…// Deserialize the class.Object x = mySerializer.Deserialize(fs);
// Read the element names and values.foreach(XmlElement xel in x.AllElements)
Console.WriteLine(xel.LocalName + ": " + xel.Value);
…
Open Content Versioning
Use the “version” tag defined in the schema to make versioning decisionspublic string AddSale
([XmlElement(Namespace="http://sales")] Sale sale)
{switch (sale.version) {
case "1.0": return DoAddSale(sale);default: return DoAddSaleV2(sale);
}}
VERY loosely typed, but still as type-safe as can be!!
Versioning & Remoting
Server Activated Objects (SAO):Server controls which version is activatedIf no version info sent from client, latest version is instantiatedVersion can be coerced via config file:
<service> <wellknown mode="SingleCall“
type="Hello.HelloService,MyHello,Version=1.0.0.0, [strong name]"
objectUri="HelloService.soap" /> <activated type="Hello.AddService, MyHello“ /> </service>
Client Activated Objects (CAO):Client controls which version is activated by the serverServer must activate version of the assembly that the client app was built againstCannot coerce the version number at the server
More remoting & versioning
Object references follow the same rules as for SAO’s and CAO’s
The object reference carries version info, but the previous rules are maintained
Object Marshalled By Value (MBV) only includes version info if:
BinaryFormatter is used
SoapFormatter + config declaration is specified:
<formatter ref="soap" includeVersions="true" />
Database Versioning
This is VERY hard to do!
Usually involves a data manipulation and migration process
Customizing a replicated version at a point in time is a good solution
Requires EXTENSIVE testing
Expect (& plan for) downtime
Often requires duplicate hardware rig
Avoid if possible through careful DB design at the outset!
Suggested Reading And Resources
Visit the Microsoft Press Kiosk today to receive Visit the Microsoft Press Kiosk today to receive 40%40% off books off books purchased from Amazon.compurchased from Amazon.com
Microsoft Press books are available at the TechEd Bookstore Microsoft Press books are available at the TechEd Bookstore and also at the Ask the Experts area in the Expo Halland also at the Ask the Experts area in the Expo Hall
The tools you need to put technology to work!The tools you need to put technology to work!
TITLETITLE AvailableAvailable PricePrice
Building XML Web Services for Building XML Web Services for the Microsoft .NET Platformthe Microsoft .NET Platform
Scott Short Scott Short
TodayToday $59.99$59.99
Additional Reading And Resources
The tools you need to put technology to work!The tools you need to put technology to work!
TITLETITLE AvailableAvailable PricePrice
TodayToday $49.99$49.99
.NET Web Services: Architecture .NET Web Services: Architecture and Implementation with .NETand Implementation with .NET
Keith Ballinger Keith Ballinger
Essential .NET, Volume I: The Essential .NET, Volume I: The Common Language RuntimeCommon Language Runtime
Don BoxDon Box
TodayToday $49.99$49.99
Community Resources
Community Resourceshttp://www.microsoft.com/communities/default.mspx
Most Valuable Professional (MVP)http://www.mvp.support.microsoft.com/
NewsgroupsConverse online with Microsoft Newsgroups, including Worldwidehttp://www.microsoft.com/communities/newsgroups/default.mspx
User GroupsMeet and learn with your peershttp://www.microsoft.com/communities/usergroups/default.mspx
evaluationsevaluations
Conclusion
There is no single silver bullet today for versioning or deployment
But we’re working on it ;)
Consider a toolset that suits your needs
.NET Provides very powerful deployment, configuration & versioning facilities
But plan carefully
Aim for automation – helps ensure reliable & repeatable deployments
Test test and test again!
And when you think you’ve tested enough …… Test again, just to make sure
© 2003 Microsoft Corporation. All rights reserved.© 2003 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.