470 likes | 803 Views
PC01. Web Services In Native Code. Nikola Dudar Program Manager Microsoft Corporation nikola.dudar@microsoft.com. Windows Web Services API. Connecting native code and web services Win32 API No dependency on .Net Framework Interoperability with WS-* SOAP stacks
E N D
PC01 Web Services In Native Code Nikola Dudar Program Manager Microsoft Corporation nikola.dudar@microsoft.com
Windows Web Services API • Connecting native code and web services • Win32 API • No dependency on .Net Framework • Interoperability with WS-* SOAP stacks • Windows Communication Foundation (WCF) • ASP .Net XML Web Services (ASMX) • Non-Microsoft stacks • System Component of Windows 7 • Available for Windows XP/Vista/2003/2008
Web Services Refresher Client Web Service Endpoint Endpoint C B A A B C Endpoint Service Proxy A B C Endpoint Code A B C Generator WSDL Code Service Host Generator XSD
Windows Web Services API Layers • Your Application Code • Service Model • Channel Layer • Async Context • Errors • Heap • XML Layer • Network I/O
Service Model • Automatically manages communication • Service Proxy on client • Service Host on service • Message exchanges as function calls • Client calls generated function • Server implements callback • Driven from Contract • WsUtil.exe generates C code from WSDL/XSD
demo Building A Client To WCF Service Nikola Dudar Program Manager Windows Web Services API
Windows Web Services API • Your Application Code • Service Model • Channel Layer • Async Context • Errors • Heap • XML Layer • Network I/O
Channel Layer • Full control over communication • Message • Data sent or received • Consists of body and headers • Channel • Abstraction for message exchange protocol • Unified API for all transports (HTTP, TCP, UDP) • Properties to tweak different settings
demo Setting Channel Properties When Building A Client To WCF Service Nikola Dudar Program Manager Windows Web Services API
Security Description • Securing message exchange on the channel • Transport security • HTTP: SSL • TCP: Windows SSPI • Message plus Transport security (Mixed Mode) • Username/Password, Kerberos APREQ, XML Token, Secure Conversation Token • Basic support for SAML and federation • No support for Full message security mode
demo Setting Security Description In A Client To WCF Service Nikola Dudar Program Manager Windows Web Services API
Windows Web Services API • Your Application Code • Service Model • Channel Layer • Async Context • Errors • Heap • XML Layer • Network I/O
XML Layer • Full access to content of messages • Unified API for all encodings • Text, Binary, MTOM • SOAP subset of XML 1.0 (No DTD) • XmlBuffer • In-memory store for XML data • XmlReader and XmlWriter • Forward only access • Integrated canonicalization (C14n)
Serialization • Mapping C data types to/from XML types • WsUtil.exe can generate C types from XSD structPurchaseOrder{int id;}; <PurchaseOrder> <id>123</id></PurchaseOrder>
demo Taking Advantage Of Serialization In A Client To WCF Service Nikola Dudar Program Manager Windows Web Services API
Windows Web Services API • Your Application Code • Service Model • Channel Layer • Async Context • Errors • Heap • XML Layer • Network I/O
Supported Configurations • Transports • HTTP, TCP, UDP • XML Encodings • Text, Binary, and MTOM • Envelope • SOAP 1.1 and 1.2 • Addressing • WS-Addressing 0.9 and 1.0 • Metadata • WSDL 1.1, XML Schema 1.0 • WS-MetadataExchange 1.1 • WS-Transfer March 2006 • Security • WS-Security 1.0 and 1.1 (partial) • WS-Trust February 2005 and 1.3 (partial) • WS-SecureConversation 1.1 and 1.3 (partial) • Policy • WS-Policy from March 2006 and v.1.2 • WS-Policy Attachment from March 2006 and 1.2 • WS-SecurityPolicy 1.1
Getting Started With WWSAPI • PDC 2008 build of Windows 7 • Webservices.Dll in System32 • PDC 2008 build of Windows SDK • Wsutil.exe • Webservices.h and webservices.lib • Documentation with samples • Windows XP/Vista/2003/2008? • Wait for system update around Windows 7 Beta
Additional Resources • Technical details • Slides 25 -45 • Documentation in Windows SDK • Related talks and Hands on Labs • PCHOL12: Windows Web Services API • PC26: Building Applications with MFC
Additional Resources • Networking Developer Center on MSDN • http://msdn.microsoft.com/network/ • Connect • https://connect.microsoft.com/wndp/ • Blogs • http://blogs.msdn.com/nikolad/ • http://blogs.msdn.com/haoxu/ • http://blogs.msdn.com/wndp/ • Email • nikola.dudar@microsoft.com
Questions? • Networking Developer Center on MSDN • http://msdn.microsoft.com/network/ • Connect • https://connect.microsoft.com/wndp/ • Blogs • http://blogs.msdn.com/nikolad/ • http://blogs.msdn.com/haoxu/ • http://blogs.msdn.com/wndp/ • Email • nikola.dudar@microsoft.com
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
WWSAPI And WCF • WWSAPI is peer to WCF • Use WCF in managed code • Use WWSAPI in native code • Similar programming models • XML, Message, Channels (message-oriented) • Service Model (function-oriented)
Cross Layer Functionality • Error object • Stores information on root cause of an error • Also used in reporting SOAP faults • Heap • Internal storage when messages sent and received • Simplifies error prone "Alloc/Free" pattern • Async Context • Enables asynchronous requests
Error Handling Details • Most functions return HRESULTs • Most functions have an optional WS_ERROR* parameter • Set of property values • Zero or more error strings • Reset error object after an error occurred • Also used for reporting SOAP faults
Heap Details • Specialized allocation pattern • Simplifies error prone "Alloc/Free" pattern • Accumulated allocation, free all at one WS_HEAP* heap;WsCreateHeap(INFINITE, 0, &heap, error);for (...){ Data* data;WsAlloc(heap, sizeof(Data), &data, error);WsAlloc(heap, sizeof(Data), &data, error);WsResetHeap(heap);}WsFreeHeap(heap); Frees all allocations
Service Proxy Details • Client side proxy for a service • Creating Service Proxy requires • Channel Type • Channel Binding • Service properties (optional) • Security description (optional) • Opening Service Proxy requires target URL • Many operations can be called on opened proxy • Reset and re-use after close
Service Host Details • Runtime for hosting a service within a process • Endpoints must be defined before creating Service Host
Service Endpoint Details • Many endpoints allowed per one Service Host • Endpoint is • URI on which it is hosted • Channel type • Channel binding • Security description • Service contract • Authorization callback • Endpoint properties
Service Contract Details • Metadata for a service • Table of callbacks that implement service operations
Channels Details • Channel Type • Direction and session information for a channel • Channel Binding • Transfer protocol • Security description • How to secure transfer • Channel properties • Additional optional settings
Channel Properties Details • Properties can be set on channel creation • WS_PROPERTY parameter to WsCreateChannel • Properties can be changed after channel is created • WsSetChannelProperty • Properties can be retrieved • WsGetChannelProperty ULONG timeout = 1000; // 1 secondWS_PROPERTY properties[1];properties[0].id = WS_CHANNEL_PROPERTY_SEND_TIMEOUT;properties[0].value = &timeout;properties[0].size = sizeof(timeout);WsCreateChannel(WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_CHANNEL_BINDING_TCP,&properties, 1, &securityDescription, &channel, error);WsSetChannelProperty(channel, WS_CHANNEL_PROPERTY_SEND_TIMEOUT, &timeout,sizeof(timeout), error);
Listener Details • Service side object that creates channels • Server can accept channels from the Listener • Listeners maintains queue of channels ready to accept
Channel Security Details • Specified when creating a channel • Transport security • HTTP: SSL, Header auth: Basic/Digest/SPNEGO/NTLM • TCP: Windows SSPI • Message security • Username/Password, Kerberos APREQ, XML Token • Secure Conversation support • Basic support for SAML and federation
Message Details • Encapsulates data transmitted or received • Can be used without a channel • Headers buffered in memory • Body is streamed • Properties specify optional settings
Asynchronous Execution Details • Passing non-NULL WS_ASYNC_CONTEXT to functions allows asynchronous execution • Function return value indicates asynchronous completion • Callback is invoked to signal completion
Performance – Memory WWSAPI
Performance – Memory WWSAPI
Performance – TCP Throughput WWSAPI
Evals & Recordings Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com
Q&A Please use the microphones provided
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.