Bdotnet Ug Book Feb 2007
-
Upload
pradeep-sripada -
Category
Technology
-
view
631 -
download
2
description
Transcript of Bdotnet Ug Book Feb 2007
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 1
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 2
By: Bangalore .NET User group
For: UG Book, Vista and Office 2007 Special Edition
____________________________
FOREWORD.........................................................................................................5
B.NET Vista and Office 2007 Launch Event......................................................8
AUTHOR BIOGRAPHIES ....................................................................................9
Introducing Vista...............................................................................................11
Windows Aero ...................................................................................................12
Instant Search ...................................................................................................14
Heightened Security ..........................................................................................15
Better management ...........................................................................................15
And Much More .................................................................................................16
The Dazzling World of WPF..............................................................................17
Introduction to WPF...........................................................................................17
Architecture of WPF...........................................................................................18
Intro to XAML.....................................................................................................19
Creating a Windows WPF application ................................................................21
Styles and Resources........................................................................................21
Style Triggers: ...................................................................................................21
Data Triggers:....................................................................................................22
ControlTemplate: ...............................................................................................22
Databinding in WPF...........................................................................................22
Binding Source ..................................................................................................22
Types of Data-binding:.......................................................................................23
Commands in WPF............................................................................................24
Events in WPF...................................................................................................24
Routed Events ...................................................................................................24
WPF/E...............................................................................................................25
Summary ...........................................................................................................26
References ........................................................................................................26
SHAREPOINT EVOLUTION ..............................................................................27
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 3
Preamble ...........................................................................................................27
SharePoint Evolution .........................................................................................27
Need for WSS 3.0 & SharePoint Portal Server 2007..........................................29
Storage Features in WSS 3.0 ............................................................................30
Collaborative Features in WSS 3.0 ....................................................................30
Web Platform features in WSS 3.0 ....................................................................30
Portal Features in MOSS 2007 ..........................................................................31
Search Features in MOSS 2007 ........................................................................31
Business Process Features in MOSS 2007 .......................................................31
Business Intelligence Features in MOSS 2007 ..................................................31
Enterprise Content Management in MOSS 2007 ...............................................32
Windows Communication Foundation............................................................33
Building SOA-based applications from the ground-up........................................33
Unification of Programming Models ...................................................................33
EndPoint............................................................................................................34
Message............................................................................................................35
Introduction to Workflow Foundation .............................................................36
Introduction........................................................................................................36
Workflow – Features, Challenges ......................................................................36
WF Architecture.................................................................................................37
Workflows and Activities in WF..........................................................................38
Sequential Workflows ........................................................................................40
State Machine Workflows ..................................................................................40
Rule Based Execution .......................................................................................40
Hosting the Runtime ..........................................................................................41
Runtime Services...............................................................................................42
Conclusion.........................................................................................................43
InfoPath and BizTalk.........................................................................................44
Scenario ............................................................................................................44
Implementation steps:........................................................................................44
Create a New BizTalk Project ............................................................................45
Create ShippingOrder and ShippingOrderConfirmation Schemas......................45
Create Map from ShippingOrderRequest to ShippingOrderConfirmation ...........46
Create Shipment Approval Orchestration...........................................................47
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 4
Create Request-Response port .........................................................................48
Expose Orchestration as a web service .............................................................49
Bind Orchestration and enlist/Start the same.....................................................50
Create InfoPath form .........................................................................................51
Unwinding Cards of Windows CardSpace......................................................53
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 5
FOREWORD
By: Tarun Gulati, GM – DPE, Microsoft .
When Microsoft first pledged itself to the graphical user interface in 1983, no one could have
anticipated that it would form the fundamental basis of personal computing and create an industry
worth several billion dollars. However, it took 12 years for the concept of a 32-bit GUI based
operating system to become mainstream. Windows 95 and Office 95 were breakthrough
products when they were released – hardware compatibility touched a new height, the world
moved from 8.3 filenames to long filenames, true type fonts became available, WYSIWYG
became the norm and a new world of unprecedented opportunity opened up for developers. At
the time Windows 95 was released, there was only one book which everybody looked up to –
Charles Petzold’s “Programming Windows” – and most Windows developers who go back a
dozen years in the industry attribute their success to that particular book. Amazing how a single
book can impact a product’s success. Programmers all over the world read the book, picked up
the Win32 Reference manual, and converted their ideas into working software. The result was an
enormous developer ecosystem for Microsoft Windows which drove a virtuous cycle that led to
the world we live in today.
Interestingly, Microsoft’s success over the last dozen years has been paralleled by the growth of
the Indian economy. Consider this: in 1995, India’s GDP was 357 Billion $, and the services
sector contributed around 42% to it. Today, our GDP is over $ 3 trillion, growing at a robust 8%
and the services sector contributes over 51%. The IT sector’s contribution in the balance of
payments is staggeringly high and growing faster than any other sector. Microsoft’s success in
India is due in large part to the growth of India as a Global IT powerhouse and the expanding
base of technology professionals in the country. Its heartening to note that more than 50% of the
1.2 Million developers in the country, build applications on the Microsoft stack.
Today, twelve years after Windows 95 and Office 95 were launched, we have come a long, long
way – the industry is far larger and addressing a much wider variety of domains. Twelve years
ago, the term Internet was known to a very few people, the world wide web was in its infancy, the
browser was an obscure application which most people had no use for, and words like phishing
attacks and E-Commerce did not exist. Things we take for granted today – digital photographs,
movies, music, instant messaging, online gaming–were like science fiction, possible, but in a
distant future. That future is happening in front of us. Much the way the launch of Windows 95
and Office 95 was central to the personal computing phenomenon in 1995, the launch of
Windows Vista and Office 2007 is central to the personal computing phenomenon today. And
much the way Windows 95 and Office 95 played a pivotal role in enabling developers to convert
their vision into electrons twelve years ago, Windows Vista and Office 2007 today provide
developers an opportunity on a similar scale.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 6
Microsoft Windows Vista operating system and Office 2007 System are the result of an enormous
engineering effort which has spanned more than five years, involved thousands of engineers …
an unparalleled effort in the IT industry. The truly amazing aspect, however, is the millions of
people in the real world who will be working with the product very soon. Windows Vista and
Office 2007 are going to be available in over 70 countries in more than a hundred languages. In
India alone, over 1.5 million developers and IT Professionals will be involved in working with
Widows Vista and Office 2007. The opportunity for innovation is huge – software no longer
operates in a stand-alone fashion. The most interesting applications have processing which runs
on a server somewhere on the Internet, and the user gets to experience it using a smart client-
side application which allows offline usage and automatic data-synchronization. Vista and Office
provide several features for enabling this very interesting type of application which would be
ubiquitous in a couple of years. With fundamental engineering innovations like the Windows
Presentation Foundation, developers and designers can work together to create immersive user
experiences hitherto only seen in Games, and all this for a fraction of the effort that it took earlier.
With technologies like Windows Communication Foundation, it will be really simple to consume
and provide sophisticated services using the web-services standards. Office 2007 provides a
way to connect information workers with data locked up in Line of Business Enterprise
applications in a seamless fashion, and a hub for collaboration software. And all of this is possible
using a single programming model - .Net Framework, and a single set of tools – Visual Studio. As
developers, we have never had it this good.
For the Indian developer, the opportunity is two-fold: it is not just the tools, but also our market
which is providing amazing scope for innovation. The accelerating economy and other factors like
a high standard of education, a large working populace and a complex multidimensional market
have caused India to be used as a test-bed for many strategic initiatives by multi-nationals and
global influence groups. What this means is that India is witnessing an investment in innovative
ideas and models that has not been seen anywhere or anytime else in the history of the planet.
Obviously such innovation cannot happen without support from Information technology, and this
opens up a huge opportunity for developers and technology companies based out of India. The
corollary is that as a nation we would miss our bus to being an economic superpower unless our
developers and technology companies rise up to the challenge of enabling these very innovative
initiatives to be successful. The Indian developer must realize her potential so that the nation can
realize its destiny.
For all the potential of our market, the sophistication of the Microsoft stack, and the opportunity it
creates, we developers still need guidance. Twelve years ago, it was one book written by a
single individual. Today, there are hundreds of books available on how to build applications using
Windows Vista and Office 2007. So what is special about this book, whose copy you are perhaps
reading on your computer screen right now? (and if it is a Windows Vista machine with an LCD
monitor, you would notice that it is so much easier to read, thanks to some groundbreaking
innovation in typography technology) What makes this book special is that it is not written by a
professional author. It is written by people like you – developers who create applications on the
Microsoft platform on a daily basis. Fellow travelers who have come forward to share their
experiences with you on a voluntary basis without any monetary gains. So what you would read
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 7
here is an unbiased view of the world from the point of view of people who do not have an inside
track at Microsoft, who have as much access to technology resources as you have. They are
brilliant in their mastery of technology and want to share their learnings so that your journey on
the path of learning is that much easier. Twelve years ago, the book by Mr. Petzold was
instrumental in creating an ecosystem of Windows developers. I am sure, this book, written by a
community of experts would be just as influential in creating an ecosystem of developers who
would create great software using Windows Vista and Office 2007 in India.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 8
B.NET Vista and Office 2007 Launch Event
Feb 3rd 2007, Bangalore
The B.NET user group witnessed another landmark event on February 3rd – the community
launch of Windows Vista & Office 2007. On 3rd, we had the developer track and 4th the IT Pro
track. The event was held in NMKRV College Jayanagar, the same venue where we had the
Visual Studio 2005 Launch Community launch last year. The developer track focused on what
Vista and Office had in store for developers. The event was organized as a half-day event with as
many as five sessions and about ten community speakers. The sessions covered a breadth of
topics that would peck a developer’s interest, particularly .NET 3.0. Several key technologies and
aspects of the new products were also addressed. For example, the new 2007 Office Server
System. The tone of the presentations was not formal, thereby encouraging several interesting
questions from the audience. The event concluded in a fun way - with a Quiz based on the topics
dealt with over the day, and some trivia on the B.NET community itself. The quiz saw an active
and enthusiastic participation.
Many thanks to the members of the community to have made this a grand success. Special
thanks to SymIndia for conducting the Quiz, and their tremendous help in the overall organization
of the event.
Thanks,
B.NET Team
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 9
AUTHOR BIOGRAPHIES
Arun Balachandran has been with SymIndia since 2002. He has a BE degree in Electronics and Telecommunications from Pune University. He is an MCP in Microsoft SQL Server. He has been selected by Microsoft Developer Support to conduct training on C++, COM, .NET basics and Scripting (DS Core Program) for which he was certified as the Best Trainer of the Month in April 2006. He has successfully conducted workshops on Share Point Portal Server 2003 & 2007, SQL Server 2005 and Design Patterns. He is also active on SQL User Groups on the net.
Email: [email protected]
Chaitra started her career with Infosys. worked with Microsoft Solutions group of Infosys for 2.5 years. And now working with Intel Technologies for the past 1.5 years. She is primarily involved in designing and developing applications using Windows forms, Smart Client Technologies, Web Services, AJAX and ASP.NET technologies. And she is an active member of B.NET.
Email: [email protected]
Kashinath works for Intel Technologies, Bangalore. Prior to joining Intel, he worked for Wipro Technologies, First American Corporation and Texas Networks. He has been speaking on .NET and related technologies in the B.NET user group. Kashinath is Co-founder / Active Member/ Presenter of B.NET. Kashinath is also a Microsoft MVP since 2002. Email: [email protected]
Manoj G is a Computer Science Engineer from RVCE, Bangalore, and currently works for Cognizant Technology Solutions (http://www.cognizant.com/) He has been working with Microsoft technologies from the very beginning of his career and is currently a .NET junkie. He takes a lot of interest in reading technical articles and enjoys writing them, too. Other interests include watching motor sports, especially Formula 1! Email: [email protected] Blog: http://msmvps.com/manoj
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 10
Meena K has BE degree in Electronics and Communications and holds a Post-Graduate Degree in Management from the Indian Institute of Management, Bangalore. She is the Technical Director of SymIndia that specializes in Corporate training and consultancy. Meena specializes in MS Technologies with particular focus in COM, .NET Technologies and Servers such as BizTalk Server 2006, SQL Server 2005 etc. She is a regular invited speaker to deliver sessions on state-of-the-art technologies in forums like PDC, TechEd, and Software Architect Meets, Product launches etc. For more details about Meena and her organization, please contact www.symindia.com Email: mailto:[email protected]
Niraj Bhatt is co-founder of company called Ardent Collaborations which focuses on software development, consulting & mentoring. Currently he leads the team on Microsoft technologies with focus on design & architecture providing services to fortune clients’ worldwide. Email: [email protected].
Praveen Srivatsa has over nine years of experience in delivering solutions on Microsoft platforms. A graduate from REC, Surathkal, Praveen has worked with iFlexSolutions, Aditi and Orbit-e Consulting for clients in Europe, North America and East Asia building business frameworks for various domains. His favorite industries include Investment Banking and Retail. As part of the MSDN Regional Director Program since 2000, he has spoken at over 50 MSDN sessions and is a regular speaker at premier Microsoft events like Tech.Ed, DevDays, and the Software Architect Forum where he has consistently got top ratings.. Email: [email protected]
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 11
Introducing Vista
By Praveen Srivatsa .
In this part we will be looking at key features of Vista and why it is the most comprehensive OS update
to date from Microsoft. While we cannot cover all the features of any OS in a short article, this article will
highlight a few of the key OS feature that makes life easier for a standard user.
The Vista Desktop
Most users are forgiven if they feel that Vista is only about a new user interface. That is one of the
most visible and compelling enhancements that Vista has introduced – bringing high end graphics
into main stream applications. But under the hood, Vista also packs a large number of
productivity features that makes Vista suitable for a new generation of applications that leverage
a user experience that is richer in media elements.
A few of the interesting Vista features include :
1. Windows Aero – the new user experience that enables a applications to harvest richer media
experiences as well as provide users with compelling user-interfaces that are not restricted to
the WinForms – battleship grey forms or the WebBased – html flow based interfaces.
2. Media Center – A confluence of media features that makes the OS richer for home users who
want to store pictures and videos and organize/share the same.
3. Instant Search – search “everywhere” that comprehensively searches for everything – e-mails,
documents, media, internet, programs, computers, people – from one single point.
4. Heightened Security – a secure environment by default that ensures that a document that
describes the steps to secure your machine is no longer required.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 12
5. Better Management – Simpler options to install and deploy the OS and a much faster install
and boot times.
Windows Aero
Windows Aero offers a premium user experience that makes it easier to visualize and work with
your information and offers a smoother, more stable desktop experience. By leveraging the
graphics driver, it ensures that the CPU is loaded much less resulting in a better performance
(when a decent graphics driver is available). Using vector graphics to render the UX, the output
scales to multiple resolution seamlessly. The key
functional features in Windows Aero include the
following.
Glass. Aero features windows that are truly
translucent. This “glass” effect allows you to more
easily focus on the content of a window, while
providing better context for the surrounding elements on your desktop. For added personalization,
you can change the color, the saturation, and even the level of transparency, to get exactly the
look and feel you want.
Dynamic windows. When minimized, a window will subtly animate to a specific location on the
taskbar, making it easier to locate when you need it later.
High dots per inch (DPI) support. Previously, the Windows interface and many third party
applications did not adequately support screens that were capable of outputting greater than 96
DPI. The experience was that these interface elements were too small to read and, as a result,
people would end up returning these more capable screens. This was especially problematic for
laptops with very small screens. Windows Vista can now comfortably scale up its interface as well
as non-DPI aware applications to 144 DPI. The benefit is that users who need to use a high DPI
screen for demanding applications no longer have to trade off usability.
Live taskbar thumbnails. With Windows Aero, live taskbar thumbnails show you the contents of
any windows that are currently open on your desktop. When you pause your mouse pointer over
a tile on the taskbar, you see the “live” contents of the corresponding window without having to
bring that window to the
foreground.
Smoother-performing
desktop. When you use Aero,
open windows glide across
your screen when you move
or resize them. You’ll see no
redraw artifacts, latency, or
“tearing” effects that
sometimes appear on existing computers, particularly in windows that display dynamic content
such as video. The Windows Aero experience also reduces graphics driver-related system
crashes and blue screens.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 13
Digital Media Center
With Windows Vista, Windows
Media Center will no longer be a
separate edition, but simply an
integrated experience within the
Windows Vista Home Premium
and Windows Vista Ultimate
editions. This provides a single
place to store and organize
pictures, music and videos. It also
integrates with a TV Tuner input to
provide a TV feed. The user can
watch TV, record the same and re-
play the same. It can also get the TV program guide and thus can become a single point home
digital-entertainment HUB.
Windows Media Center in Windows Vista features some great advancements over previous
versions, including an improved user interface with easier navigation and breakthrough media
visualization. Windows Media Center also offers built-in support for archiving TV shows directly to
video DVDs, faster overall performance, and an improved platform for content owners to deliver
new online entertainment services and experiences.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 14
Instant Search
With a new tool in Windows Vista called Instant Search, you are never more than a few
keystrokes away from whatever you’re looking for. This feature, which is available almost
anywhere you are in Windows Vista, enables you to type a filename, a property, or even text
contained within a file, and it returns pinpointed results. It’s fast and easy. Instant Search is also
contextual, optimizing its results based on
your current activity—whether it’s
searching Control Panel applets, looking
for music files in Windows Media Player,
or looking over all your files and
applications on the Start Menu.
In an organizational environment, all the
data important to users isn’t necessarily stored on a single desktop. The next-generation search
capabilities in Windows Vista are designed for use in distributed data environments in several
important ways:
Offline Folders. Information workers using server shares to store personal or project data
frequently want that content to be available offline. In Windows Vista, taking folders or files offline
has the effect of copying that content locally and creating a sync relationship between the local
and server copies. Doing this also ensures that the local content gets indexed, thus giving users
an easy way to search over server-based content.
Windows Vista Computer to Computer Search. By default, a search includes
only the local computer. However, users can search other Windows Vista-
based PCs connected to their network by using a distributed search. With a
distributed search, the target computer instantly provides search results, but
only if the user is authorized to access those files.
Office Outlook and SharePoint offline documents. With the 2007 Microsoft
Office release, you can take Microsoft Office SharePoint libraries and
documents offline via Microsoft Office Outlook, and Windows Vista lets you instantly search over
that offline Office SharePoint content along with the normal e-mail search of Outlook.
Third-party data source support. Developers can use iFilters and protocol handlers to add their
data to the Windows Vista system index so users can instantly search over that content.
Removable/connected hard drives. Users frequently connect standalone hard drives to their PCs
for additional storage, backup, or archival purposes. This content can be added to the
Windows Vista system index so users can easily search that content.
Generic file shares and legacy computers. Windows Vista provides search performance equal to
Windows XP search over these devices. This is because fast search works only when the content
is indexed by the local PC or when the remote location supports distributed searches.
Windows Vista also introduces a new feature called Search Folders—when you click on a Search
Folder, it instantly runs a search. Windows Vista comes with many preconfigured Search Folders,
such as Important E-mail, which instantly shows you all your flagged email, and All Attachments,
which shows you all files that are attachments. You can also create and save your own Search
Folders. For example, you can design a search for all documents authored by John that contain
the word project somewhere within them.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 15
Heightened Security
Although the IT industry has become much more effective in limiting the effect of
malicious worms and viruses, threats continue to evolve as hackers become
more sophisticated and as users become more connected to each other and to
the Web via broadband Internet access.
Building on the security advances in Windows XP Service Pack 2 (SP2),
Windows Vista has been engineered to be the most secure version of Windows
ever developed by Microsoft.
While Windows XP SP2 ensured that the OS can be secured completely, the user experience in
such an environment was not the best. Once the OS is secure, users had to logon as guest or a
low privilege user and for each task that required additional permissions, they had to log off,
logon as a separate user with additional privileges and then log back on as the low privilege user
again. Vista simplifies the whole process with User Account Control or UAC.
Most user activities, such as surfing the Web, sending email, and using productivity applications,
do not require administrative privileges. Yet most people log on to their home PC with an account
that has full administrator privileges. This puts the PC at greater risk from viruses, spyware, and
other threats.
User Account Control (UAC) in Windows Vista makes it easier to use your PC with standard user
privileges. You can create a separate user account for each member of the family and control
which websites, programs, and games each person can use and install. UAC also helps families
with children protect their PCs from malware such as viruses, worms, and spyware that might be
hidden in programs that appeal to children. UAC makes it practical to give children their own
standard user account, so that if a child tries to install a new piece of software, the system will
prompt for an administrator account password to approve the action.
Even when you use an administrator account, UAC provides additional protection. By default,
most programs run with the permissions of a standard user, which limits the potential damage
they can do. If you need to start a program that requires administrator privileges,
the system will prompt you for an administrator password.
Better management
New technology in Windows Vista makes your PC significantly more responsive
in performing everyday tasks. Improved startup and sleep performance helps
both desktop and mobile PCs get up and running more quickly. And Windows
Vista manages both memory and input/output (I/O) devices more efficiently,
making the computer more consistent and more responsive to user applications.
And as the computer ages, a number of features work together to help keep the
PC running as quickly as when it first arrived.
Windows Vista also incorporates a new approach to addressing performance issues and offers a
Performance Information and Tools Control Panel that helps users easily understand their PC’s
performance characteristics and manage and troubleshoot performance issues. Because some
Windows Vista features and third-party applications will work only if your machine meets certain
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 16
hardware requirements, a new Windows Experience Index scale helps you understand how your
PC measures up and whether those features and applications will work on your machine.
In addition to in-the-box improvements, Windows Vista is designed to take advantage of the latest
hardware to improve system performance. Windows ReadyBoost (formerly code named “EMD”)
uses flash memory to boost performance without the need for you to add RAM. Windows
ReadyDrive (formerly code named “Hybrid Hard Drive”) takes advantage of new hybrid hard disk
technology to improve reliability, battery life, and performance. Finally, state-of-the-art self-tuning
and diagnostics make it much easier for users and information technology (IT) administrators to
manage performance effectively.
And Much More
Other than the above, Vista also offers key enhancements in Pen Inputs, Ink/Handwriting
recognition, Speech Recognition, Side Shows etc. Integrating the Tablet-PC and the Media
Center features (there are no longer separate Tablet-PC or Media Center editions of Vista), Vista
brings a richer experience to a digital media hungry consumer. At the same time by leveraging
advances in search and providing a better performance in a safe and secure environment, it
improves the confidence of corporate users. In all, Vista is set to become the most widely used
OS on most client environments in the coming year.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 17
The Dazzling World of WPF
By Chaitra N .
Introduction to WPF
Windows Presentation Foundation (WPF) is a productive, unified approach to UI, Media, and
Documents that you can use to deliver unmatched user experiences to your customers.
Some of the features of WPF are:
1. WPF is the next-generation Windows smart-client UI technology. The same XAML code base
can be used in Windows and Browser applications.
2. Integration: Windows Presentation Foundation offers a unified set of graphics APIs
This helps in 2D and 3D graphics development.
3. Vector graphics. As described in the introduction, Windows Presentation Foundation takes full
advantage of the powerful Graphical Processing Units that are part of modern PC systems. At its
heart, the composition engine is vector-based, allowing for scaling of all output to match the
resolution of a specific machine.
4. Declarative programming. Windows Presentation Foundation introduces XAML (eXtensible
Application Markup Language), an XML-based language for instantiating and populating nested
object hierarchies. Importantly, the XAML / code-behind model embodied in Windows
Presentation Foundation allows designers and developers to work collaboratively on client
application design and development, using tools such as Microsoft Expression.
5. Easy deployment. With support for both standalone applications and Web-browser
applications, Windows Presentation Foundation offers the best of both deployment models.
6. Document lifecycle. Windows Presentation Foundation introduces a new set of document and
print technologies. Applications that need to persist data to a local store can use the Open
Packaging Conventions, a ZIP-based packaging convention shared with Office 12 that supports
core properties and custom metadata, digital signatures and rights management functionality. For
applications that want to share documents for collaboration across multiple machines, even
without the application installed, the XML Paper Specification (XPS) allows visuals to be fixed in a
printable, portable format.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 18
Architecture of WPF
This diagram shows the basic architecture for WPF. Notice all the different media types (in
yellow) that are handled by WPF: Vectors, Bitmaps, 3D, audio and Video, Text and Effects!
Second, notice how the animation capabilities of WPF span across all the media types, allowing
you to animate any kind of content. The WPF Composition Engine (in black) is one of the
revolutionary features of WPF. This engine provides capability of having live content within
content. This means that you can have a 3D object rotating inside a Button control and
furthermore you can have a video projected over the surface of the 3D object!
System requirements for developing WPF applications:
1. Visual Studio 2005
2. .Net Framework 3.0
3. Windows SDK which comes with a XAML pad
4. Visual Studio 2005 extension for WPF
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 19
Refer the site: http://msdn2.microsoft.com/en-us/windowsvista/aa904955.aspx
Intro to XAML
XAML is the grammar of WPF applications. Microsoft has provided us with a free XAMLPAD so
that we can learn and explore its capabilities. XAML is case sensitive.
The XAML pad has a splitter window. On the bottom part of the window we can type in XAML
content and this will be reflected on the top part.
When we open the XAML pad we see the following lines:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid> </Grid></Page>
Page is a Container used to hold the elements. Instead of Page it can also be Windows,
StackPanel, WrapPanel, DockPanel or Canvas
Grid is used to split the container into rows and columns so that we can place the UI element at a
particular row, column position.
Eg: Below is an example of creating a Button in XAML.
<Button Height="100" Width="100" Background="Red">
<MediaElement Source="C:\Paris.wmv" Volume="0" />
</Button>
As we see from this example the content of the Button need not always be text, we can place a
Media file as the button content.
Then we can also do some transformations with the button. We can define a ScaleTransform and
use that as a Button triggering action.
Eg:
<Button.RenderTransform>
<ScaleTransform x:Name="sctCity" CenterX="60" ScaleX="1" ScaleY="1"/>
</Button.RenderTransform>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.MouseEnter">
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 20
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="sctCity"
Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
To="1.2" Duration="0:0:0.5" />
<DoubleAnimation
Storyboard.TargetName="sctCity"
Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
To="1.2" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Button.MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="sctCity"
Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
To="0.5" Duration="0:0:0.5" />
<DoubleAnimation
Storyboard.TargetName="sctCity"
Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
To="0.5" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>
We will learn more of XAML in the further samples.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 21
Creating a Windows WPF application
On creating a new .Net Framework 3.0 -> Windows Application (WPF) we get a Windows.Xaml
and a Windows.Xaml.cs file. I can copy the button example and paste it in Xaml file. When I run
the application, the XAML loader at runtime map object elements into classes or structures,
attributes into properties or events, and XML namespaces to CLR namespaces. In a similar way
a XAML Browser Application (XBAP) can be created.
Styles and Resources
Style is a convenient way to set property values of UI elements.
E.g.: To set the style of all the TextBlock elements on a Window, we can use the following code
<Window.Resources>
<Style TargetType=”TextBlock”>
<Setter Property="FontFamily" Value="Comic Sans MS"/>
<Setter Property="FontSize" Value="14"/>
</Style>
<Window.Resources>
Resources are used to define the styles globally for all the Elements on that container.
To apply the style to a particular TextBlock give a name to the style with an x:Key = “stylename”.
Then in the TextBlock set Style= {StaticResource stylename} . When we place the content
withing {} brackets they are called “MarkUp Extensions”. The brackets will indicate to the XAML
loader that they should not be considered as static text. We can use a Setter to attach a value to
an “Attached UI property” like FontSize.
We can override a style and change the values of the properties defined:
<Style TargetType="{x:Type Button}" x:Key="BasedOnButtonStyle"
BasedOn="{StaticResource myStyle}">
<Setter Property="FontSize" Value="20"/>
</Style>
Style Triggers:
We can declare a certain property values to get set when a certain triggering action happens:
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red"/>
</Trigger>
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 22
</Style.Triggers>
When there is more than one condition then we have to apply MultiCondition triggers.
Data Triggers:
We can define a textbox “firstName” and a Button and say that the Button should only be
enabled if the textbox is not empty,
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=firstName, Path=Text.Length}"
Value="0">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
ControlTemplate:
In WPF, ControlTemplate is used to define the appearance of a control. Properties of the control
can be set.
Eg:
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid> <Ellipse Fill="{TemplateBinding Background}"/>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
Databinding in WPF
Data binding is the process that establishes a connection between the application UI and
business logic. In WPF, dependency properties of elements can be bound to CLR objects
(including ADO.NET objects or objects associated with Web Services and Web properties) and
XML data.
Binding Source
• Common Language Runtime(CLR) objects: Can bind to properties of classes
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 23
An ObjectDataProvider can be used for this purpose.
<ObjectDataProvider x:Key="myTodoList" ObjectType="{x:Type local:Tasks}"/>
• ADO.NET: Can bind to Ado.net objects like DataTable and DataView.
• Xml Data: We can access the Xml Data using an XML Data Provider object
<XmlDataProvider x:Key="InventoryData" XPath="Inventory/Books">
An XPath can be used to query the XmlDocument, XmlNode or XmlElement.
• DependencyObjects: Can bind to properties of a dependency object.
Types of Data-binding:
• OneWay binding causes changes to the source to automatically update the target, but
changes to the target are not propagated back to the source.
Eg: Binding in XAML
<TextBlock Text="{Binding Source={StaticResource myDataSource},
Path=PersonName}"/>
• TwoWay binding causes changes to either the source or the target to automatically
update the other
• OneWayToSource is the reverse of OneWay binding; it updates the source when the
target changes. An INotifyPropertyChange property change mechanism is used for this
purpose. The UpdateSourceTrigger action happens either on LostFocus or
PropertyChanged Event.
• Using Collection objects: Any collection that implements IEnumerable interface can be
used. WPF provides the ObservableCollection class, which is a built-in implementation of
a data collection that exposes the INotifyCollectionChanged interface.
• Using DataTemplates: This depicts the visual representation of data.
Eg:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=TaskName}" />
<TextBlock Text="{Binding Path=Description}"/>
<TextBlock Text="{Binding Path=Priority}"/> </StackPanel> </DataTemplate>
</ListBox.ItemTemplate>
• CollectionView and CollectionViewSource: CollectionView as the layer on top of the
binding source collection that allows you to navigate and display the collection based on
sort, filter, and group queries, all without having to manipulate the underlying source
collection itself. CollectionViewSource class is the Extensible Application Markup
Language (XAML) representation of the CollectionView class.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 24
Commands in WPF
WPF uses predefined RoutedCommands from one of the Base libraries. The
ApplicationCommand class has some predefined commands like Cut, Copy and Paste. The
MenuItem class also has some predefined commands. We can use these system commands in
our normal click events. We can define listener methods to execute when this system command
is called.
Eg: In the example below a Button is using the Application close command
<Button Content="Close" Command="ApplicationCommands.Close"/>
Then we define to methods one to check if the close command can be executed, this can be used
to do some validation if the window can be closed at this point. Then the Execute method is
called to close the application.
<Page.CommandBindings>
<CommandBinding Executed="OnCloseExecuted"
CanExecute="OnCanCloseExecute"
Command="ApplicationCommands.Close"/>
</Page.CommandBindings>
The routed command model in WPF has four main concepts: the command, command source,
command target and the command binding. In the previous example Close is the command,
ApplicationCommands in the command source, Button is the target control and the click event of
the button is the command binding.
Events in WPF
There are 2 types of Events in WPF:
1. Standard Events Eg: like the Button.Click event
2. Routed Events.
Routed Events
In a routed event model an event can travel along element tree route. The event can invoke
handlers
on listeners at the element tree root, and then route to successive child elements along the tree
node route towards the node element that is the event source. Or, the event can invoke
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 25
listeners on the source element, and then route to successive parent elements until reaching the
element tree root.
What is the use of Routed Events?
Using routed event we can use a single handler at the Window level for all the click events of
the all the Buttons on the Window. In the example below we are handling the button click event at
the StackPanel level using the concept of Bubbling.
Eg:
<StackPanel Background="LightGray" Orientation="Horizontal"
Button.Click="CommonClickHandler">
<Button Name="YesButton" Width="Auto" >Yes</Button>
<Button Name="NoButton" Width="Auto" >No</Button>
<Button Name="CancelButton" Width="Auto" >Cancel</Button>
</StackPanel>
The same thing can be done in code by attaching the Button.Click event to a StackPanel using an
AddHandler. At the parent level we can stop the routing of the event by saying handled = true.
Eg: Attaching an Button click event
Button b2 = new Button();
b2.AddHandler(Button.ClickEvent, new RoutedEventHandler(Onb2Click));
Routed events use one of three routing strategies:
� Direct: Only the source element handles the event
� Tunneling: Initially, event handlers at the element tree root are invoked. The event then
travels a route through successive child elements along the tree node route, towards the
node element that is the event source (the element that raised the event).
� Bubbling: Event handlers on the event source are invoked. The event then routes to
successive parent elements until reaching the element tree root.
WPF/E
WPF Everywhere is the name of a cross-platform cross-browser strategy to enable browsers to
render rich content. This is a light weight component of 1MB which is a plug-in to the browsers.
When a WPF application having rich graphics needs to be used by clients then need not have
.Net 3.0 Framework on their systems, they need to just download this package.
The package can be downloaded from the following link:
http://msdn2.microsoft.com/en-us/asp.net/bb187452.aspx
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 26
Summary
WPF is a way of creating dazzling graphics rich applications. The same code base can be used
across Web and Windows application. WE use the same Visual Studio 2005 controls at the back
end. So Migrating to WPF is suggested only if we want to have a UI centric application. If we are
developing a data-centric application then .Net 2.0 is good enough for it.
References
http://blogs.interknowlogy.com/AdamCalderon
http://sandbox.netfx3.com/
http://msdn2.microsoft.com/en-us/library/ms754130.aspx
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 27
SHAREPOINT EVOLUTION
By Arun Balachandran .
Preamble
SharePoint has, so far, been a Technology focusing on the collaborative aspects of office
documents and web content. SharePoint Portal 2007 (MOSS 2007) has been designed to cater
not only to these collaborative features, but also to cater to business process automation,
business intelligence, search, portal and enterprise content management features. The platform
for SharePoint 2007 is Windows SharePoint Services 3.0 (WSS 3.0). This platform has been
integrated with ASP.NET 2.0, so that there is extensibility in authentication, storage and design of
a basic website. This article talks about the features of MOSS 2007 as well as WSS 3.0, so that
designers & developers get to know the available choices, given the business requirement.
Note: Only the important features have been covered as a brief overview here. Please refer the
following documents for the rest of the features and all features in-detail:
WSS Guide–URL: http://www.smbnation.com/pdfs/smbnation2006/WSSGuide.pdf
SharePoint Guide–URL: download.microsoft.com/download/5/D/C/5DC09195-7D74-4A5D-AFED-
62C000648A15/SharePointGuide.doc
SharePoint Evolution
Information workers use an array of tools and devices to share information with others, like E- mail,
desktop applications, mobile devices, Web browsers, Web conferencing, portals, and line - of -
business applications. These tools and devices are used by individuals, teams, departments and
enterprises.
Collaboration is Information sharing. Collaboration goes through the following phases:
1. Creation
2. Approval
3. Notification
4. Information Search
5. Administration &
6. Archival
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 28
Some elements that are used for collaboration are as follows:
1. Web content
2. Office documents
3. Emails
4. Surveys
5. Discussions
6. Tasks
How to achieve collaboration
1. Access information thru disparate data sources
2. Put information to work
3. Access information from a single point to improve decision-making abilities
4. Integrate information from multiple applications including third-party applications
5. Search information store–web servers, secure web servers, file servers, and exchange public
folders, Lotus notes, and Active directory
6. Notify, new or changed information
7. Personalize information:
a. Personalize content and layout that is preferred by individual users in the team
b. Creating Personal and Public view of content
Benefits of online collaboration are as follows:
1. Team members can be spread out in different locations
2. Suppliers can discuss directly with their customers without moving out from their location
3. Companies can compete for business across long distances by offering the ability to regularly
meet with their customers and collaborate on projects without incurring the expense, effort and
lost work-time due to travel to their site
4. Companies can effectively utilize:
a. Resources within their own company / divisions
b. External resources and expertise, and
c. Low cost suppliers
that would otherwise be too far away to use effectively
Microsoft’s solutions for collaborative platforms have been as follows:
1. FrontPage extension–Server-side companion of FrontPage Web development.
2. Office Server extension was launched in conjunction with Office 2000–Server-side services for
new Web Folders, discussions, and subscriptions.
3. Microsoft’s SharePoint Team Services (STS) with SharePoint Portal Server 2001 (SPPS
2001).
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 29
4. Windows SharePoint Services 2.0 (WSS 2.0) with SharePoint Portal Server 2003 (SPPS
2003).
Limitation of the above products:
1. Websites created by SharePoint Team Services are difficult to extend.
2. SPPS 2001 was not designed for management of thousands of sites.
3. SPPS 2001 & STS had no consistent support process for storage technology. Data was stored
in disparate data sources.
4. WSS 2.0 & SPPS 2003 overcame the drawbacks of the previous versions, but still had the
following drawbacks:
a. No integration was possible with ASP.NET 2.0.
b. Flexibility in authentication (No custom-authentication provider).
c. Lack of a workflow engine for human workflows.
d. Lack of mixture of collaboration and content management features.
Eg: - For an online flight service we would like to collaborate flight-schedule details
and booking details, but from the angle of business, the Airline team would like to
share new services information. This leads to change in webcontent and is initiated by
the business people. We need to use Content Management Server (CMS) for content
editing and SPPS 2003 for collaboration.
e. Lack of feature to search relational data source, without having to write custom filter.
f. Lack of extensive use of metadata for lists & Document libraries. Lack of features to
have multiple document types in one document library, so that same workflow can be
supported for related set of documents.
Eg: - All finance-related documents (Word, Presentation, Excel etc.) should go
through a single type of workflow.
Need for WSS 3.0 & SharePoint Portal Server 2007
Requirements that needed to be addressed:
1. Site for storing private and shared information
2. Productivity tools like Office for collaboration
3. Portals to organize the content and provide search and index services
4. Creation of services that can be used throughout enterprise
5. Consolidation of storage for content
6. Creation of policies for managing the expiration of the content
7. Creation of complex workflow for human-related tasks, like document approval
8. Item level security for document libraries and lists
9. Pluggable authentication providers
10. Combination of content management and collaborative features
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 30
11. Automation of business process
12. Representation of business data in a dashboard format
13. Combination of the collaborative features of ASP.NET 2.0 for ease of development
14. Integration of enterprise portal with Line - of - Business Application and Business data.
All these requirements gave rise to the new version of WSS & SharePoint portal Server 2007.
The features given below satisfy all the above requirements.
Storage Features in WSS 3.0
1. Support for Policy, auditing and workflow
2. Indexes for large lists and document libraries, so that queries are faster
3. Support for extension of document libraries and lists with custom column-properties
4. Support for Content Type, a feature where in reusable definition of document types could be
used across organizations.
5. Support for document policy, auditing and compliance features for document libraries
6. Provision to create custom workflows on items in lists & document libraries
7. Provision for new fields, like append only and multi-value lookup
Collaborative Features in WSS 3.0
1. Provide Blogs and Wikis site template, for social meeting
2. Provide people and group’s list–a central unified place to communicate with people
3. Provide collaborative items to be posted through mails
4. Provide lightweight task-management functionality like Gantt charts
5. Provide for RSS-enabled program to retrieve List and document library data
6. Provide Integration with office applications like Outlook, PowerPoint, Excel, Access and
SharePoint Designer
Web Platform features in WSS 3.0
1. Support editing of site-templates using Visual Studio 2005 and SharePoint Portal Designer
2. Support site Promotion i.e. subsites can be promoted in the site hierarchy
3. Support for integration with ASP.NET, from development-perspective to use the following
features:
a. WebPart Infrastructure
b. Provider Model
c. Master pages
4. Support for pluggable authentication provider. We could write our own authentication provider
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 31
5. Support for Folders & item level security for lists and document libraries
Portal Features in MOSS 2007
1. Provide new portal site templates for division, organization and corporate internet presence
portals
2. Support social networking Web Parts that use information of organization, communities and
electronic communication. Social network help establish personal connections
3. Support LDAP pluggable authentication provider
4. Support for mobile devices
5. Enhancements in user profiles
Search Features in MOSS 2007
1. Feature of business data search to index and search relational database Eg: - data from a
CRM system
2. Feature of content scopes to help broaden and narrow the scope of search
3. Support to search people and domain experts within the organization using the LDAP store
Business Process Features in MOSS 2007
1. Provision of browser based InfoPath forms, for individuals who do not have InfoPath on their
machines
2. Provide Forms created in MOSS 2007 based on XML standards
3. Usage of InfoPath form features without writing any piece of code
4. Support to design forms just once to be deployed both for rich clients like Office 2007 as well
as for thin clients
5. Support Single Sign On to use custom as well as third-party pluggable credential providers
Business Intelligence Features in MOSS 2007
1. Support for Excel services that publish ExcelSheets to SharePoint sites. Users do not require
Microsoft Excel to view the published ExcelSheet
2. Support Programmatic access to ExcelSheets
3. Provide Data connection libraries that can publish connection files, so that users can find the
data sources they need
4. Provide Business Data Catalog (BDC) that allows data from back -end system to be included
in the SharePoint List, Web Parts, pages and search result
5. Provide Web Parts to display line of business analytical data using BDC
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 32
6. Provide dashboard facilities to use Key Performance Indicators (KPI) for business data
analysis
7. Provides Report Centre Websites for management of reports, spreadsheets, and data
connections
Enterprise Content Management in MOSS 2007
This area is divided into three parts:
1. Document Management
a. Support creation of custom document workflow for approval
b. Support for new document Management Site template
c. Support for new document Library, divisional Library and translation Library Site
template
2. Record Management Provides:
a. Policy and auditing feature for content – type and policy – based document retention
and expiration schedule
b. Windows Right Management Services integration
c. labeling and bar-coding features, without physically modifying a document
d. Record Repository built on WSS
e. Email content to be stored as record
f. Management of mails and stored folders
3. Web Content Management Supports
a. Authoring and approval of web content
b. Web publishing and Deployment
c. New templates for portal sites
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 33
Windows Communication Foundation Introduction
By: Manoj G .
Today, the world is connected. Applications simply don’t exist as independent silos. Large and
small bodies of software are being connected together, and the need for it is more than ever
before. Development platforms are maturing at a fast rate to help developers build connected
systems in a fast and efficient way. The Windows Communication Foundation is a key pillar to the
.NET Framework (Version 3.0) which helps build these powerful connected systems on the
Windows platform.
It can be asserted that WCF didn’t appear out of the blue, but rather was a result of an evolution
of technologies and practices. The arrival of WCF can be attributed to two prime reasons which
are explained in the following sections.
Building SOA-based applications from the ground-up
As businesses grow, the needs of software supporting them start to get more and more complex.
The ever increasing need to build and integrate with large enterprise-scale applications have
resulted in the emergence of new ways in which software is architected, and the way connected
systems are conceived. Service-Orientation is one such methodology which is gaining
tremendous traction over the last few years. Service Orientation involves a set of principles which
entails creation of loosely-coupled services that interoperate in a technology-agnostic manner.
While there could be numerous representations or definitions of what Service Oriented
Architecture is all about, this article would refrain from delving into the specific details. One is
encouraged to look at Don Box’s article (http://msdn.microsoft.com /msdnmag /issues/ 04 /01
/Indigo/) for an insightful introduction to the core tenets. While the presented tenets provide a
guideline as to what services should be like, realizing those services with the existing set of tools
and technologies is a challenge. The basic reason being – the concepts put forward by service
orientation are not made explicit here. The need of the hour is a framework which helps build
connected systems using SOA from the ground up. The Windows Communication Foundation
addresses just that. It brings developers closer to SOA than its predecessors.
Unification of Programming Models
The Windows platform has evolved over the years, and so has several distributed communication
technologies. The Windows platform has always provided a wide variety of options to deal with
different needs of distributed communications. We have had MSMQ for reliable, durable &
asynchronous messaging, DCOM for distributed component calls, and with the advent of .NET,
ASMX /WSE (for web services) and Remoting. Each of these different technologies was powerful
in its own right, and addressed a specific need. The real problem was that each of these came
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 34
with its own programming model. For example, it was difficult (if not impossible) to use MSMQ as
a transport option for web services. Queued Components (COM+) was the only way to develop
components which used queued asynchronous messaging. The ability to compose these different
technologies together by providing a unified programming model brings new powerful and
exciting prospects to developers. WCF was designed specifically to makes this possible. While
providing a unified model, WCF also embraces the latest set of open standards and protocols that
have emerged on web services scene, especially the WS-* standard stack.
WCF, in a nutshell, is all about facilitating message exchanges between endpoints. Note that
‘message’ and ‘endpoint’ are underlined. Well, these are but, what WCF is all about. These are
concepts through which SOA is realized. There is a clear shift from the world of RPC (Remote
Procedure Cal) to message exchanges.
EndPoint
If any entity needs to communicate with the world, it does so with Endpoints. Endpoint comprises
of three elements (commonly called as ABC):
� Address (Where) - Where can I find the service, the URI?
� Binding (How) - How can I communicate with the service? What are security
requirements, transport protocols, encoding requirements etc.?
� Contract (What) – What is the structure of the messages that I need to communicate
with the endpoint? What are the message exchange patterns (like Request/Reply,
OneWay etc)
A WCF service, which can be defined as any program which communicates through message
exchanges, would therefore, have at least one endpoint; it could have multiple based on different
combinations of bindings, contracts or endpoint addresses. If you really look at it, the concepts
embodied by WCF aren’t new. They were pretty much present in ASMX. What lacked was that
these concepts/abstractions were not explicitly codified in the ASMX (ASP.NET)
framework. ASMX just seemed to be a quick way to get .NET classes to talk SOAP. So, caught in
a world of classes and attributes, developers lost sight of underlying concepts that manifested as
wsdl:portType, wsdl:port, wsdl:message and wsdl:binding.
WCF, on the other hand, makes these concepts explicit, as seen in the ServiceEndPoint, Binding,
ContractDescription, and EndPointAddress classes in the System.ServiceModel namespace. It is
this object model that makes WCF very powerful. The number of out-of-the-box bindings
available and the existence of several extensibility points speak of the raw power of the WCF
programming model. Also, this architecture is what makes unification of several programming
models like MSMQ, COM+, and WSE etc. possible.
While the concepts of Address, Binding and Contract have been codified into the
System.ServiceModel namespace and one can create a service endpoint programmatically, an
endpoint can be entirely constituted though configuration, and most typically, that is case when
services are deployed.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 35
Message
“Message”, which can simply be thought of as the data/document/information exchanged
between endpoints, is a first class citizen in the WCF programming model. Unlike its predecessor,
where messages meant no more than an XML document (or stream) representing the SOAP
envelope, WCF provides much better representation and finer control over messages. Messages
are represented by the Message abstract class in the System.ServiceModel.Channels
namespace.
The structure of the message is governed by its contract. While everything in WCF boils down to
messages, Like ASMX, but in much richer way, WCF provides a programming model (through
System.ServiceModel) which absolves the developer from understanding the nitty-gritty’s of
message exchanges. Classes can be annotated with attributes (metadata) which determine how
objects are converted to messages and back. This approach is usually termed Code-First. On the
other hand, WCF also allows one to generate code based on pre-created WSDL and XSD
schema descriptions. This approach is called Contract-First approach.
While System.ServiceModel largely represents the face of WCF programming, the grunge work
of message passing is carried out by the Channel layer. The WCF runtime transforms object to
messages which then pass through a stack of channels. Each channel represents a protocol, in
accordance with the binding selected for the endpoint. One can build his own channel, and this
ability speaks about the power and flexibility of the WCF programming model.
Conclusion
This article basically gave a broad overview of the core concepts underpinning WCF without
delving into programming details. WCF offers both a simple programming model for services, and
a rich set of extensibility points. WCF eases development of connected systems by providing a
model which not only leverages the best of existing distributed technologies, but also embodies
several concepts which form the basis of tomorrow’s service-oriented applications.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 36
Introduction to Workflow
Foundation
By Meena K .
Introduction
With the advent of Workflow Foundation (WF), Workflow capabilities are being built as part of
.NET framework. With WF providing a strong foundation and infrastructural support, it is now
straightforward to build workflow-based applications using WF. Both System and Human based
workflows are supported in WF. As part of WinFS, WF provides both APIs and tools to embed
workflows into applications. This article provides a basic and broad look into the features offered
by WF.
Workflow – Features, Challenges
A workflow is a model of a Business Process represented by a collection of activities, involving
people and/or software, to accomplish an explicitly stated goal. Examples of workflow are
Insurance claim processing, Loan Request Processing, Leave Processing, etc. Some workflows
like online order processing may involve only system processes; others, like Leave processing
may involve human interaction with or without system processes.
An activity represents a unit of execution in a workflow. Activities form the basic building blocks in
a workflow.
As an illustration, the Order Processing workflow in an organization may be defined as follows. “
When orders are received, an acceptance mail is sent to the client. Small-sized orders require no
authorization while large-sized orders do require authorization from Credit Management Officer.
For authorized orders, three sets of accounting entries are passed. For every item in the order,
allocation happens, depending on the inventory availability of the order. Once allocation is
completed for all items, the shipment can happen.” As one can observe, the workflow involves
distinct set of actions to be performed in a specific sequence, and, may involve many features:
actions to be done in sequence, parallel, in a loop, and conditionally,
In whichever application we use, we observe that there is some degree of flow–both control and
data—in it. When it comes to implementing a workflow, many applications follow the “Roll your
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 37
own model” approach. While this approach is appropriate for simple workflows, the challenges
increase with complex workflows. Some challenges are:
� Workflows may be long running; an Order may be processed in hours, days, or even
months. In such scenarios, state management and state persistence of the workflow
instances are issues to be handled properly.
� Tracking a running workflow instance becomes an important requirement so as to
respond to specific queries made about it: for example, knowing the status of an order
that is being processed.
� When human beings participate in a workflow, we require flexibility; some steps may be
overridden, some steps in the workflow may be skipped, and so on. For example, we
may skip authorization based on discretion of Credit manager even though the order is
not small.
These challenges demonstrate the need for built-in infrastructure for workflow modeling and
implementation in a framework.
WF Architecture
WF has gone through a lot of name-changes. Windows Workflow Foundation abbreviates to WF
because the World Wildlife Foundation has a trademark on "WWF".
The key components of WF are:
� Workflow: A set of activities grouped together to implement a Business process
� Activity: The building block of a workflow, representing a unit step of execution
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 38
� Base Activity library: A library containing a built-in set of activities
� Runtime Engine: A library that executes the workflow and provides core services
� Host Process: A Windows application that hosts the Runtime Engine and the workflows
executed by the engine
� Workflow Designer: A graphical tool to create and maintain workflows
� Runtime Services: A set of services provided by the host for persistence, transactioning,
tracking, etc.
The workflow can be modeled as a collection of activities. Out of the box, Microsoft provides a set
of built-in activities. Examples include activities to call external s/w like invoking a web service,
and, calling on a method on an object external to the workflow. The common constructs like
conditionality using IF-ELSE, looping with WHILE, pausing with DELAY, etc. are also activities.
One could create custom activities easily in WF.
The WF runtime is a library. To run an instance of the workflow, a host is required. This host
could be any Windows application.
The Runtime provides a set of non-pluggable services such as rule service, low level scheduling,
state management, etc. In addition, a set of pluggable Runtime Services are provided.
Workflows and Activities in WF
In WF, a workflow is a class. For example, a sequential workflow in C# looks like :
using System.Workflow.Activities;
public class OrderProcessingWorkflow: SequentialWorkflow
{
…
}
In WF, an activity is also a class. A custom activity in C# looks like:
using System.Workflow.Component Model
public class AuthenticateActivity: Activity
{
// Activity’s state goes here
// Properties, methods and Events go here…
}
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 39
An activity may be simple or complex. It may be composed of other activities. To create custom
activities, you can extend existing activities or create brand new ones by implementing IActivity
interface.
The Base Activity Library provides control structure support with activities such as IF-ELSE,
WHILE, LOOP, etc. Built-in activities are available to invoke a web service, execute another
workflow, execute code within the workflow, execute code on an object outside of the workflow,
and so on. Activities may be executed in sequence or in parallel, using the SEQUENCE and
PARALLEL activities. Activities may be suspended and resumed using the respective activities.
TERMINATE activity can be used to terminate an activity during execution.
How are the classes for Workflow and activities created? Well, the easiest way to create a
workflow is by using the Workflow Designer which makes the creation as a “Drag and Drop”
exercise! Using the toolbox, one could drag and drop the activities. As we drag and drop activities
and set properties for the same, the designer modifies the source code in workflow class. The
designer-generated code has two parts: to instantiate objects for each activity class and set their
properties, and to construct an object graph to establish relationship among the objects. This is
similar to WinForms, in terms of what happens we drop the controls onto a Form.
Using the Workflow Designer is not the only choice; Workflows can also be defined purely using
XAML, using the markup-based option. There are multiple options now available; one could
design a workflow purely using XAML, following the declarative approach or purely using code,
following the imperative approach or choose a combination of both. Irrespective of the option
chosen to create it, a workflow is always compiled into a .NET assembly.
The following gives an example of how declarative style can be combined with code behind:
<SequentialWorkflowActivity x:Class="ABCCompany.OrderProcessing"
x:Name="OrderProcessingWorkflow"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
<CodeActivity
x:Name="AcceptOrderActivity"
ExecuteCode="AcceptOrder_ExecuteCode" />
</SequentialWorkflowActivity>
Here, the code-behind class looks as follows:
public partial class OrderProcessingWorkflow :
SequentialWorkflowActivity
{
private void AcceptOrderActivity_ExecuteCode(object sender, EventArgs e)
{
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 40
…
}
}
How does this combination work? The XAML above will transform into a partial class by name
“OrderProcessingWorkflow”, the name got from x:Name attribute. The code behind contains the
partial class with the same name as given in the Name attribute.
Sequential Workflows
A sequential workflow is one that has a well-defined path, with begin and end visible clearly. It
follows a pre-determined sequence of course of flow. The sequential flow can contain parallel
branches, conditionality, looping, etc. It could also respond to events generated outside of the
workflow. This kind of workflow is suitable to model system-based workflows which are
deterministic and formal in nature.
State Machine Workflows
This type is suitable for those workflows which involve human interaction. The activities are
organized into a finite state machine. We define a set of states and events that trigger the
transitions across these states. With human interaction involved in a workflow, there is a need for
a lot of flexibility: the exact course of action is not known right upfront, i.e. it is non-deterministic.
Or, some steps may have to be skipped on-the-fly (e.g. bypass authorization for a Gold
customer), cancel/override some steps.
Sequential workflows could also respond to events fired from outside the workflow; hence, they
are not purely sequential. Also, in a state machine workflow, we could have a sequence of steps
performed during state transition. Well, we get the best of both worlds! Combining the two styles
provides a very powerful, unified way to address the requirements of complex workflows that
demand a rich set of both—system-related activities, as well as diverse human interactions.
Rule Based Execution
Typically, business processes use rules at different points in the workflow. For example, “If Order
Amount less than Rs. 10,000, it requires no authorization”, “If a customer is not a Gold or
Platinum customer, approval is required from Customer Manager as well as Credit Manager”. To
implement business rules, there are many choices in WF.
An IFELSE or WHILE activity requires a condition which is by itself a business rule. We can
express this condition programmatically, using code; an alternative, the declarative style, is,
define a rule condition which is stored in a separate XML file. At runtime, the Rule Service
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 41
evaluates the condition’s expression and returns a Boolean value. Note that the RuleCondition
definition is serialized into a <WorkflowName>.rules file that is added to the project.
For more complex rules, a Policy activity is provided. Many a time, a set of rules may have to be
executed as a set. An example is a set of verifications to be done on an incoming order before it
is accepted for processing. Using the Policy activity, we can define a rule set, which is essentially
a collection of rules. Each rule follows the same format: IF <condition> THEN <action> ELSE
<action>. At runtime, the Rule Engine checks the conditions for all the rules for which state
information is available; if the condition evaluates to true, the rule is fired. Firing of a rule may
itself change the state of the workflow and some rules may become candidates for evaluation; the
rule engine may execute these rules in the second pass. This technique called, Forward chaining,
provides support to define and implement complex rules. In addition, the features include options
to suppress re-evaluation of rules to avoid infinite loops, assigning priority to rules to control the
sequence of evaluation, marking a rule as active or inactive.
Hosting the Runtime
Since the WF Runtime is a library, it requires a hosting environment. This could be provided by
any kind of Windows application: a Console application, ASP.NET application, a web service,
Winforms application etc. WF could be used along with WCF in an application and this opens out
a lot of opportunities to write workflows integrated with distributed application development.
Understanding how the host starts running a workflow is easy. An instance of the
WorkflowRuntime class is created and the Runtime is started. StartWorkflow method is invoked
which creates an instance of the workflow class and begins the execution of the same.
Using System.Workflow.Runtime;
class OrderProcessingHost
{
static void Main()
{
// Create an instance of WorkflowRuntime class
WorkflowRuntime runtime = new WorkflowRuntime();
// Start the runtime
runtime.StartRuntime();
// Create an instance of Workflow class and start the same
runtime.StartWorkflow(typeof(OrderProcessingWorkflow));
...
}
}
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 42
Runtime Services
Every host provides a set of runtime activities. Persisting the state of the workflow when it is
idling, tracking a workflow, providing support for transactions are examples of such activities.
Since the services are pluggable, we can choose the services required based on our application
needs.
WF provides default implementations of a set of services. Custom Services can be created
easily.
As an example, consider the need to persist the run-time state of a Workflow instance. Scenarios
are: when the workflow is idling, when a workflow is terminated, etc. A way of stating that our
workflow requires this service is shown below:
Using System.Workflow.Runtime;
class OrderProcessingHost
{
const string ConnectionString = "Data Source=.\\sqlexpress;Initial
Catalog=WorkflowPersistence;Integrated Security=True";
static void Main()
{
// Create an instance of WorkflowRuntime class
WorkflowRuntime runtime = new WorkflowRuntime();
//Create and add Persistence Service to the Runtime
runtime.AddService(new SqlWorkflowPersistenceService(ConnectionString);
// Start the runtime
runtime.StartRuntime();
// Create an instance of Workflow class and start the same
runtime.StartWorkflow(typeof(OrderProcessingWorkflow));
...
}
}
In the sample, we have used an out-of-the box persistence service based on SQL Server
database. The persistence service handles actually saving and loading the workflow state
information to or from a data store. When the WF Runtime decides that persistence should occur,
it engine calls methods in the persistence service to save state information about the workflow
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 43
instance. Similarly, to restore a previously persisted workflow instance, it calls methods in the
persistence service to load this state information.
Conclusion
This article has barely scratched the surface, to say the least, about WF framework. Microsoft has
added workflow capabilities to any kind of application written on Windows, thereby brining
workflow capabilities to mainstream application development. Complex Business processes are
now simple to model and implement. WF supports both declarative and imperative styles to
define workflows. We now have a unified workflow model, integrating system and human
workflows, along with infrastructure providing a set tools. The architecture of WF allows
extensibility at every level, be it creating custom activities or custom runtime services.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 44
InfoPath and BizTalk
By: Kashinath TR .
Setting up EAI/B2Bi infrastructure for small organizations may not be affordable, but still they can
be a part of B2Bi by creating simple desktop infrastructure for sending/ receiving data to trading
partner's integration servers through web service. In this article we will explain how to create
simple InfoPath forms which can consume web services exposed by some other organization's
integration server (BizTalk).
InfoPath is simple, rich and front-end application which comes with MS-Office, using this user can
enter information in forms which internally sends/stores data in XML format. And about BizTalk, it
is a third generation integration product from Microsoft. It includes developer toolset, business
process management, and it can also expose business process as a web service.
You can also make use of BizTalk Server's Business Activity Monitor for real time notifications,
wherein you can track business processes end-to-end, which is powerful in itself, but BizTalk’s
compatibility with InfoPath allows you to conveniently connect business processes into other
Office 2007 tools like Excel, Access, etc., or into appropriate network distribution chain or any
ERP systems.
Scenario
We will build a simple business process to automate Shipping Order Request. In this scenario
User will complete shipping order request form and submit it. In the background it will be
submitted to trading partner's BizTalk orchestration through web service. And Business process
will accept Shipping Order Request only if shipment's country is India else it will reject the Order.
Implementation steps:
1. Create Shipping Order Request Schema
2. Create Shipping Order Confirmation Schema
3. Create Map
4. Create Orchestration (which decides whether order to be accepted or rejected)
5. Deploy the Orchestration
6. Expose Orchestration as web service
7. Create InfoPath form, which consumes Orchestration web service.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 45
Create a New BizTalk Project
We will create a new BizTalk project called FebExCargo application.
Create ShippingOrder and ShippingOrderConfirmation Schemas
We will add two schemas to the project which we created, one for Shipping Order request and
another for Confirmation. In confirmation schema we will promote ShippingOrderStatus and
RejectReason element, so that we can update these element's value in Orchestration.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 46
Create Map from ShippingOrderRequest to ShippingOrderConfirmation
We will create a map to transform data from Order request to Order confirmation. Actually all the
data which we received through request will be sent back in confirmation message but we will be
updating OrderStatus and OrderRejectReason if order is rejected.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 47
Create Shipment Approval Orchestration
We will add new orchestration to the BizTalk Project which we created. In this we will have
business logic which will decide whether Order request to be Accepted or Rejected.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 48
Create Request-Response port
Create Request-Response port to support web services for receiving and sending the content
back to InfoPath form.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 49
Expose Orchestration as a web service
Once we are done with Orchestration which contains actual business process, will publish the
orchestration as web service. And to do that we will use BizTalk web services publishing wizard.
And in the wizard you follow the following steps to achieve the same.
� Select “Publish BizTalk Orchestration as Web services” and click Next
� Select your BizTalk assembly and click next.
� By default it selects the ports, so do not change anything and click next.
� Type the target Namespace or just go ahead with the default namespace specified by
wizard.
� Give the web service project name and check “Allow anonymous access and Create
BizTalk receive locations” and click next.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 50
Bind Orchestration and enlist/Start the same
Once you are done with creating web service and receive locations, now you can go to BizTalk
server explorer and bind the orchestration with receive ports which we created recently and also
Host.
Well, now we are ready with the Business process system which is exposed to public as web
service, so that InfoPath users can create a simple form to send request to it.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 51
Create InfoPath form
We will see how to create an InfoPath form which consumes the trading partner’s web service.
Follow the steps given below to create your InfoPath form.
� Design a form by using data connection wizard, where in we will select web service as a
connection type
� Specify “how form should work with web service” as “Receive data”
� Then in next step give BizTalk’s web service’s WSDL path
� Then Select Operation name
� And in next step enter a name for your connection and click finish.
Now you will get a connection with elements name in data source window of InfoPath, so drag
and drop the data source elements to Form and click preview to test your form. And your form
should look like below.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 52
Now our InfoPath application is also ready. So you can send sample data and test your
application’s connectivity. As per our business logic in orchestration shipments to other country
will be rejected and only India shipments will be accepted and processed.
This is how we can create simple B2Bi system which can be cost effective, fast in development
and effective.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 53
Unwinding Cards of Windows
CardSpace By: Niraj Bhatt .
Normally when you are introduced to a new technology you study the theory and rationale behind
it. This will be normally followed by sample which makes you say AH-HA!!! For a change let’s see
sample first to demonstrate what Windows CardSpace looks like, what it can do for you & how
would you use it. Along the way we will see why it’s there.
The easiest way to get feel of CardSpace is to install .NET framework 3.0 & IE 7.0, open IE & key
in the following URL: https://sandbox.netfx3.com. Click on the Join link displayed on the page.
The page looks like any other page you might have visited - asking for your name, password,
address, etc. But what is more important is the option next to it which reads – Select an
information card
Figure 1: Alternative way of joining: https://sandbox.netfx3.com
If you are some one like me who loves change, by all means you will click on that. Voila!!!
CardSpace is in front of you1. The dialog box gives you decent introduction of what CardSpace is.
Click ok and you will get information about the site which you are visiting. You were over a secure
connection so CardSpace just got some information from site’s high assurance certificate. It
prompts you with the information including the site’s logo if available. After all, it’s important for
you to know whom you are communicating with & communication should happen only after your
consent. This can go a great way in preventing Phishing. As of now let’s be generous & say Ok.
Next click - Choose a card to send.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 54
Figure 2: CardSpace displays the discovered identity of the party you are communicating with.
The next screen that appears says whether you want to select a personal card (also called self
issued card) or a managed card. Personal cards are one wherein you just say or claim anything
about your identity & opposite party doesn’t care. It’s like signing up in hotmail with user name as
Bill Gates. Of course this won’t work in all contexts & that is why there are issued cards that are
managed by others. E.g. is your id card which you wear daily to office – its issued card managed
by your company. Here company makes some claims about you & it might useful for some one
who trusts your company. Yes, I am referring to that Citibank credit card guy whom you would
have often heard saying - “I just need a photo copy of that ID”. After all he trusts your organization
& hence the card. ID makes sense to him but it may not to that policeman who caught you for
speeding couple of days back. You give him that company’s ID & he puts it in a waste paper
basket. He is looking for a different managed card – Driving license.
This is an important difference between Live ID (.NET passport) & CardSpace. Live ID believes in
one identity to be used every where but in real world that’s just not possible. So with CardSpace
you can have multiple personal or managed cards. You select card specific to given
requirements. Though, in some scenarios you might use the same card. For instance a credit
owned by you is accepted by both Amazon & EBay. In identity parlance your company is called
identity provider, policemen or Citibank agent are relying parties & you are the user. You select
the card given by an identity provider depending on the requirements of relying party. So, let’s
move on. Click on - Create a Personal Card.
Figure 3: CardSpace dialog to select a personal or managed card.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 55
And there you see a bunch of regular information to be entered. There are some fields which are
mark required (* and red font) & some are not. Important thing to notice over here is the site
(relying party) decides which the fields (claims) are required. In this case the site says it needs
your Email ID, First & Last Name. Even if you keyed extra fields CardSpace will send only the
claims required. Let’s face it – nothing in this world is fully secure. The more you expose your
identity to others more risk you carry of someone misusing it. Why not give just what is asked?
This is one the laws of a successful identity metasystem2. After entering required information click
– Save - Ok.
Figure 4: Required fields are in red font. Only these fields will be delivered to requesting site.
At this juncture CardSpace will confirm you the information (Security Token) which you are above
to send. Note the communication can happen only over Https & hence it’s secure. Site can use
this information to sign you up. (There is also a Personal identifier which guaranteed to be unique
for a given site; site can use it to remember you on next visit). Next time you want to login to the
site, you can use the same card (https://sandbox.netfx3.com – Sign in page). Hence the obvious
benefit is a single card can be used while registering for similar sites. Also your information is
consolidated in a single place & you type entire stuff just once. Cool!!!
Ok. I see some questions boiling in your mind. What if I go to a cyber café? Do I have to re-create
all my cards over there? Nope you don’t. You can back up your cards to file, carry in your USB
where ever you go and restore on machine you use. But what if I forget to delete my cards from
the cyber café machine (you say)? Won’t the guy coming next misuse them? Answer to that is a
PIN concept using which you can lock your cards. After all remembering one password can be a
good memory exercise.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 56
Figure 5: Unlocking a locked Card.
One more benefit of CardSpace is the consistent GUI irrespective of identity provider & relying
party you are dealing with. So, how do we integrate this with our applications? How do we build
sites which can leverage on CardSpace? Can I use CardSpace in context of Web services for
authentication & authorization? Yes you can do all that in an easy declarative way. To use
CardSpace with Web Sites you can either you XHTML or Object3 tag. To use it with other
technologies like WCF use WSFederationBinding4 with ClientCredential type set to IssuedToken.
You are advised to have a look at ready samples available with latest Windows SDK. Sequence
of steps performed internally is:
� User gets security requirements token requirements so called policy from relying part
(e.g. sandbox.netfx3.com)
� User selects corresponding Managed / personal card which satisfy the policy
requirements.
� If Managed card is selected then security token is retrieved from the corresponding
identity provider otherwise generated internally.
� Relying party is presented the security token.
As CardSpace is built on top WS-* protocols any organization can build & support similar
systems. Microsoft has been collaborating with other vendors for a wide adoption of this
wonderful technology.
That’s it. This was a very brief introduction to CardSpace and its capabilities. For more
information I would recommend you to have a look at
http://en.wikipedia.org/wiki/Windows_CardSpace which contains links to MSDN articles &
Channel 9 videos. Cheers BDOTNET.
1 Check if prerequisites .NET 3.0 & IE 7.0 are installed. Once done you can check for CardSpace
icon in your control panel.
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 57
2 For more information visit the Kim Cameron’s Identity WebBlog - http://www.identityblog.com
3 Enabling CardSpace for a website using <Object> tag.
<object type="application/x-informationcard" name="xmlToken">
<param name="tokenType"
value="urn:oasis:names:tc:SAML:1.0:assertion" />
<param name="requiredClaims"
value=http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier
/>
</object>
4 CardSpace in WCF Service using wsFederationHttpBinding
<wsFederationHttpBinding>
<binding name="requireInfoCard">
<security mode="Message">
<message issuedTokenType="urn:oasis:names:tc:SAML:1.0:assertion">
<claimTypeRequirements>
<add claimType
="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"/>
<add claimType
="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifer
"/>
</claimTypeRequirements>
<issuer
address="http://schemas.xmlsoap.org/ws/2005/05/identity/issuer/self"/>
</message>
</security>
</binding>
</wsFederationHttpBinding>
B.NET UG BOOK http://groups.msn.com/bdotnet
FEB 2007 FEB 2007 FEB 2007 FEB 2007 PAGE NO 58
Useful Links Bangalore .NET Usergroup : http://groups.msn.com/bdotnet/ Bangalore SQL Server Usergroup : http://groups.msn.com/SQLBang Bangalore Biztalk Server Usergroup : http://groups.google.co.in/group/b-bug Bangalore IT Pro Usergroup: http://groups.msn.com/bangaloreitpro/ Bangalore .NET Students Usergroup: http://groups.msn.com/bdotnetstudent Bangalore WinEmbedded Usergroup: http://groups.msn.com/winembedded India MVP Program: http://www.microsoft.com/india/mvp Microsoft Technical Communities Homepage: http://www.microsoft.com/india/communities/ Microsoft Community Alliance Program: http://www.microsoft.com/india/communities/introalliance.aspx Community Buzz Webcasts: http://www.microsoft.com/india/communities/UpcomingWebcasts.mspx