250 likes | 425 Views
Agenda. Web Services 2.0 programming model changesWeb Services InteroperabilityProtocol, generics, nillable, asynchronous supportExtensibility points in Web Services 2.0Imperative serialization of typesSchema importer extensionsInfrastructure enhancementHosting from any AppDomainHTTP compres
E N D
1. ASP.NET Web Services 2.0Alex Thissen (athissen@twice.nl)Twice IT Training
2. Agenda Web Services 2.0 programming model changes
Web Services Interoperability
Protocol, generics, nillable, asynchronous support
Extensibility points in Web Services 2.0
Imperative serialization of types
Schema importer extensions
Infrastructure enhancement
Hosting from any AppDomain
HTTP compression, configuration API, pre-gen
Questions and Answers
3. Changes in Web Services 2.0 programming model
4. WS-I Basic Profile 1.1 Profile proposed by Web Services Interoperability Organization (WS-I)
Standard for interoperability that address many incompatibilities between today’s services
“Safe” subset of several specifications
Based on best practices from field
Messages (SOAP), Description (WSDL) and Registry (UDDI)
Conformance in services is emitted using <wsdl:documentation> element
5. Basic Profile 1.1 Conformance ASP.NET 2.0 Services are BP1.1 conformant by default
Warnings or errors are generated when BP1.1 is violated
Errors only when claims are made
Claim conformance for
Web service itself
Individual portTypes, bindings or operations
6. BP Conformance for ASMX services Claim conformance using WebServiceBinding attribute
Disable warnings in web.config
7. BP for client proxies Wsdl.exe generated client proxies are also BP1.1 conformant by default
Unless WSDL of service is not BP1.1 compliant itself
WSDL tool will emit warnings for non-compliant service descriptions
8. Wire and message protocol support Protocols set now includes:
HttpGet, HttpPost, HttpPostLocalhost,HttpSoap, HttpSoap1_2
ASP.NET 1.1 suggested support for SOAP 1.2, but did not have it
SOAP 1.2 enabled by default, remove through <protocols> section
Client proxies have similar support:
WSDL tool accepts Soap1_2 value for /protocol
Proxy class has SoapVersion property of type SoapProtocolVersion
9. On xs:nillable and Nullable types Types can be made nillable:
Use Xml… attibutes
These elements will do appear, but are null
Problem for value types
Elements with xs:nillable=“true” are mapped to System.Nullable<T>
XxxSpecified no longer necessary, except in combination with minOccurs=“0”
Beta 1 had /sqltypes parameter for WSDL tool, for mapping nullable valuetypes to SQL types
10. Generics and ASMX 2.0 ASMX 2.0 has full support for generics
Server-side only: instantiated generic types
Client proxies does not use generics
Strong typed descriptions are given for web service description
No XmlInclude attributes needed
Type information in generic type is used to include correct schema information in WSDL
11. Type sharing for proxies Currently there are issues when generating types shared across multiple web services
Solving problems involved manually editing created proxy files
Wsdl.exe now has command-line switch to prevent this doubling
12. Data-binding support In VS.NET 2003 Types generated through Add Web Reference or wsdl.exe only contained fields
Data-binding requires public properties
Now types are created with public properties and private fields
Still a different type than one returned from web service
Suppress properties: /fields argument for wsdl.exe
13. Asynchronous programming model Delegate-based async model was a bit clumsy
Begin/End… + AsyncCallback delegate
Callback on thread from pool
New event-based async model uses common Framework design pattern
Similar to BackgroundWorker class
Callback is made to event-subscribers
EventArgs derived class provides results
Callback made on main thread
14. Extensibility points in Web Services 2.0
15. Custom serialization Serialization of types is performed by XmlSerializer
Only offers basic influence using Xml... attributes on fields, properties and classes
Several situations gave non-serializable types or instances
certain types such as Dictionary
circular references
Take full control over (de)serializing types
IXmlSerializable has been around since ASP.NET 1.1: DataSet only
Now available as a public interface
16. IXmlSerializable Interface contains three methods: ReadXml, WriteXml and GetSchema
When implemented XML serializer will use Read/WriteXml in favor of reflection based serialization
GetSchema is superseded by combination of XmlSchemaProvider attribute and static method of your choice
Framework types that already implement IXmlSerializable
DataSet, DataTable
XPathDocument
Types from System.Data.SqlTypes
17. Custom schema imports Influence code generated for schemas inside Web Service description
Implementation
Derive a class from SchemaImporterExtension
Override one or both ImportSchemaType methods
A lot easier than working with SoapExtensionReflector, SoapExtensionImporter and ServiceDescriptionFormatExtension, ServiceDescriptionImporter
Several changes since Beta1 to both CodeDom and System.Xml.Serialization.Advanced
18. Custom schema imports (2) Register new importer extension in machine.config
Handled in declared order, first match wins
19. Infrastructure enhancement and other new features
20. Pregeneration of serialization assemblies Assemblies are emitted by XmlSerializer when types are first serialized:
Costly hit for first client
Use a command-line tool for pregenerating these: sgen.exe
When present pregen’d assembly will be used instead of dynamic generation and compilation of serialization assembly
21. Hosting Web Services Internet Information Server now longer required
HttpListener class can listen inside any managed app
Uses http.sys from Windows XP SP2 and Windows Server 2003
22. Services configuration Object model for reading and manipulating <webServices> section in web.config
Key classes for programmatic access:
ConfigurationManager for access to .config files
WebServicesSection: typed access to section
Various …Element classes, such as WsiProfilesElement and ProtocolElement
Note: saving web.config will most likely recycle your AppDomain
23. Http Compression for Web Service replies .NET Framework now has built-in HTTP compression support
In particular: HttpWebRequest class
Generated proxy classes can decompress HTTP responses from Web Service
Use EnableDecompression property to enable
You must enable Http Compression for asmx(see KB article Q322603) on IIS server
24. Questions and Answers ?
25. Useful links Web Services Interoperability Organizationhttp://www.ws-i.org/deliverables/workinggroup.aspx?wg=basicprofile
MSDN Visual Studio sitehttp://lab.msdn.microsoft.com/vs2005 and /teamsystem
Weblogs
Christian Weyer @ http://weblogs.asp.net/cweyer
Yasser Shohoud @ http://weblogs.asp.net/yassers
Alex Thissen @ http://www.alexthissen.nl