Friday, February 20, 2009

WCF Contracts

A contract is at name implies is a standard way of describing what a service can do. Meanwhile, it is platform independent. In WCF we have 4 types of contract:
· Service Contract: It defines what a client can do with the service.
· Data Contract: It defines which data types can be transferred in the service. ( by default you can pass basic types like int, string however for custom types like a custom class you need to define the class as a Data Contract to be able to pass object of that class in the service)
· Fault Contract: It defines what are the errors raised by service.
· Message Contract: It is an extra functionality allows you to send message in a customized way (It means that you need to send a message in a specific way because let’s say there is an existing system that just understands messages in a specific way. As a user of WCF you should not usually use this as you do not need it except you are working with very specific system that needs specific messaging system)

Service Contract:
To allow a WCF Client to understand what they can do with the service you need to use Service Contract which is an attribute you need to add to the class. Also for each method that you wish WCF client to access you need add OperationContract attribute take a look at this sample

[ServiceContract]
Class MyService
{
[OperationContract]
public string MyOperation()
{
return “hello World”;
}
}

As you see in above example we have ServiceContract for the class and we have OperationContract for the methods. Some Points:
· You can apply ServiceContract to a class or interface
· You have to apply OperatoinContract for methods otherwise it will not be accessible to clients
· You can only apply OperationContract to methods
· It is highly recommended first you better create an interface and apply the servicecontract then create a class that implements the interface (the reason will be discussed further)
· Methods accessibility is not important to WCF (public, private or internal) since they are CLR concepts not WCF
· Always the default constructor will be called (avoid parameterized constructors)
· You can define a Namespace for the ServiceContract (and it is suggested to do so) to avoid collision
Please see the same sample by using interface and namespace
[ServiceContract(Namespace=”mycompany.com”)]
interface IMyService
{
[OperationContract]
string MyOperation();
}
Class MyService:IMyService
{
public string MyOperation()
{
return “hello World”;
}
}

Friday, February 13, 2009

WCF Fundamentals

To work with WCF you need to understand these elements in WCF:
1-Addresses
2-Contracts
3-Bindings
4-Hostings
5-Endpoints
6-Metada exchanges
7- Client side Programming

Addresses:
In WCF every service is associated with a unique address. Each address has two specifications. First it has the location of the service and second it has transport protocol. The location has the name of machine, a communication port and an optional specific path called URI. (URI is a unique string). WCF supports these protocols:
· HTTP : we use Http
· TCP : we use net.tcp
· Peer Network : we use net.p2p
· IPC: we use net.pipe
· MSMQ: we use net.msmq

So the address has this format:
[transport protocol]:// [machine name][:optional port number]/[optional URI]
example: Http://myserver:4040/myservice

You use each protocol based on requirement latter on when we talk about binding you will see that there are different bindings and for each binding you need to use one of the protocol then you have different kind of serialization & Interoperable functionality.

WCF & Service Oriented Architecture

Windows Communication Foundation (WCF) is a new technology in .Net 3.0/3.5 helps you to implement Service Oriented Architecture. This new technology not only allows you to work with previous services implemented by .Net Remoting or XML Web Services, but also has extensive functionality like instance management, asynchronous call, transaction management, disconnected queued calls, and security which can be applied through simple configuration.


If you are going to write a service it is better use this technology as it gives lots of flexibility. For those of you who may not work with other technologies like Remoting, COM+ or XML Web Services and may not have experience with Service Oriented Architecture I should say Service Oriented Architecture tries to provide the functionality through services which are components hosted probably in another box. Applications can use these services.

So if you have a code that you think different applications in internet / intranet may use it.You better provide that code as a service then your code centralized in one place while you can use extensive functionality through WCF.

Please read my other posts for WCF comming soon.

Steps to learn SharePoint

SharePoint is a massive product. It is so huge which makes it difficult to know all parts of it. Having said that you need to know the product and be a good user of the product itself then you can try a path to make yourself professional in this product. I believe there are two types of professionalism in SharePoint. The first one is Administration and Configuration of SharePoint. The second one is Development and Customization of SharePoint. These are steps to be a professional programmer in SharePoint:

1- Know the product and the functionality of it and the purpose
2- Be a good user of it (know how to use SharePoint)
3- Know how to install a SharePoint Server
4- Be able to understand differences between MOSS and WSS
5- Know how to use Out of the box features
6- Match the features to your company or a company
7- Understand different types of sites in SharePoint
8- Understand the connection of SharePoint and Office box
9- Be professional on creating Simple InfoPath forms
10- Configure a server farm
11- Create and manage content
12- Create a workflow
13- Manage enterprise search and indexing
14- Do Backup and recovery
15- Create a BDC
16- Develop a security topology
17- Configure other server platform to work with SharePoint
18- Know how to migrate from 2003 to 2007
19- Build collaboration and publish portals
20- Customize and brand your site with MasterPage, PageLayout, CSS, Themes and navigation
21- Customize and Create Workflow
22- How to deploy a workflow across servers
23- How to Use Form servers
24- How to use Excel Services
25- How to create Solution Package
26- How to use VS to Create Solutions

I am sure there are so many items that I missed and I need your help to add more if you think I missed something just send a post and I will add it to the list.

Anyway it is a long way to know SharePoint. At the first step my suggestion is that you can see 32 movies from Microsoft site to help you understand very basic functionalities of SharePoint.Just remember these movies are not covering all the functionalities but just part of them.

This is the list of movies to help you to get an understanding of basic features.

Demo: Configure a SharePoint Server 2007 site to receive e-mail

Demo: Deploy an administrator-approved form template

Demo: Simplify collaboration with a SharePoint team site

Demo: Streamline business processes with forms and workflows

Watch this: Create a presentation from slides in a slide library

Watch this: Create and manage a SharePoint calendar

Watch this: Find your way around a SharePoint team site

Watch this: Customize a site

Watch this: Automate business process with workflows

Watch This: Tour of My Site

Watch this: Use Word 2007 to post to a SharePoint blog

Watch this: Create a recurring meeting with a Meeting Workspace in a SharePoint calendar and then connect it to Outlook 2007

Watch this: Different ways to check documents in and out of a SharePoint site

Watch this: Make it easier to find information with views

Demo: The new SharePoint Server 2007 Fluent interface

Demo: Prepare to back up files on Office SharePoint Server

Demo: Connect people to information with portals

Demo: Enterprise Content Management with SharePoint Server 2007

Demo: Search for information on a SharePoint site

Demo: Add KPIs to your SharePoint site

Demo: Back Up Office SharePoint 2007

Watch this: Using SharePoint to manage your classroom

Demo: Display KPIs in a dashboard

Watch this: Give a user access to a SharePoint site

Watch this: Work with documents offline in Outlook

Watch this: Find just the data you need by using Filter Web Parts in a dashboard

Watch this: Use a Document Workspace to collaborate on a document from a SharePoint library

Demo: Enable Excel Services and data connections for a SharePoint team site

Demo: Make better business decisions with reports and dashboards

Watch this: Manage access to documents on My Site

Watch this: Use an approval workflow in SharePoint Server 2007

Watch this: Create and publish Web pages on a publishing site

Tuesday, February 10, 2009

Preparing a SharePoint Server

To start SharePoint what you need is an environment that is properly setup. You need so many softwares in that machine. It is almost impossible for most of us having a Server 2003 at our PCs. since most of our computers are Notebook. You need a Server 2oo3 to install SharePoint. The best way to solve the issue is that you can install Virtual PC. This Software allows you to install different OS on your computer. What you need is at least 40GB hard and 1GB of RAM then I believe you can have rather well enough machines to install SharePoint. The first step is installing Virtual PC. It is free software and you can download from this link:
http://microsoft-virtual-pc.en.softonic.com/

Then you need to install Windows 2003 in Virtual Machine.Then all you need is following this link and follow 20 Steps to install SharePoint in a virtual PC:

http://www.sharepointblogs.com/mykiep/archive/2007/04/26/step-by-step-guide-for-installing-moss-2007-on-a-vpc.aspx

Then be ready to learn about SharePoint, InfoPath and Workflow.