|
|
July 07 Service Contract - ServiceContract attribute:
- Can decorate an Interface/class
- Independent of visibility (even private classes can be exposed as services!)
- ServiceContract maps CLR interface to WCF contract
- Class can implement multiple contracts (i.e., Implement multiple interfaces)
- No parameterised constructor useful for WCF
- No static members useful for WCF
- No object reference as parameters (Primitive or data contracts only)
1: [ServiceContract(Namespace = "MyNamespace" Name = "IMyContract")] 2: interface IMyContract 3: {...}
OperationContract attribute
- Default operation name is method name
- Can provide different name for operation (Name property)
- All names in contract must be unique
- Useful in method overloading and inheritance conflicts
Binding: A way of wrapping multiple aspects of communication (Extract all these aspects out of the service implementation)
- Transport Protocols (HTTP, HTTPS, TCP, P2P, IPC, MSMQ)
- Interaction Patterns (Synchronous request/reply, Asynchronous fire-and-forget, Bidirectional Duplex, Queued and disconnected)
- Format and encoding (Plain text, Binary, MTOM)
- Security (No security, Transport security, Message security, Authenticating and authorizing callers)
- Reliability (No reliability, End-to-end reliability, Ordered/unordered)
- Transaction propagation ((client-side transaction, service-side transaction, Transaction protocols)
- Interoperability (Basic web services, WS-*, WCF, MSMQ)
Endpoint = Fusion of the Address, Binding and Contract
<system.serviceModel> <services> <service name = "MyNamespace.MyService"> <endpoint address = "net.tcp://localhost:8000/MyService/" bindingConfiguration = "TransactionalTCP" binding = "netTcpBinding" contract= "MyNamespace.IMyContract" /> <endpoint address = "net.tcp://localhost:8001/MyService/" bindingConfiguration = "TransactionalTCP" binding = "netTcpBinding" contract= "MyNamespace.IMyOtherContract" /> </service> </services> <bindings> <netTcpBinding> <binding name = "TransactionalTCP" transactionFlow = "true"/> </netTcpBinding> </bindings> </system.serviceModel>
- Programmatic Self-Hosting and EndPoint creation Example:
ServiceHost serviceHost = new ServiceHost(typeof(MyService)); Binding wsBinding = new WSHttpBinding(); Binding tcpBinding = new NetTcpBinding(); serviceHost.AddServiceEndpoint(typeof(IMyContract), wsBinding, "http://localhost:8000/MyService"); serviceHost.AddServiceEndpoint(typeof(IMyContract), tcpBinding, "net.tcp://localhost:8001/MyService"); serviceHost.AddServiceEndpoint(typeof(IMySecondContract), tcpBinding, "net.tcp://localhost:8002/MyService"); serviceHost.Open();
- Enable Metadata Exchange
<system.serviceModel> <services> <service name = "MyService" behaviorConfiguration = "EnableMEX"> ... </service> </services> <behaviors> <serviceBehaviors> <behavior name = "EnableMEX"> <serviceMetadata httpGetEnabled = "true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
- Programmatically enable Metadata Exchange
ServiceHost host = new ServiceHost(typeof(MyService)); ServiceMetadataBehavior metadataBehavior = host.Description. Behaviors.Find<ServiceMetadataBehavior>(); if(metadataBehavior == null) { metadataBehavior = new ServiceMetadataBehavior(); metadataBehavior.HttpGetEnabled = true; host.Description.Behaviors.Add(metadataBehavior); } host.Open();
- host.Close(); //With Close(), calls in progress are allowed to complete
- host.Abort(); //With Abort(), calls in progress are aborted
- Programmatic Client Config:
WsHttpBinding wsBinding = new WsHttpBinding(); wsBinding.SendTimeout = TimeSpan.FromMinutes(5); wsBinding.TransactionFlow = true; EndpointAddress endpointAddress = new EndpointAddress("http://localhost:8000/MyService/"); ServiceProxy proxy = new ServiceProxy(wsBinding,endpointAddress); proxy.MyMethod(); proxy.Close();
<%@ ServiceHost Language = "C#" Debug = "true" CodeBehind = "~/App_Code/MyService.cs" Service = "MyService" %>
<system.serviceModel> <services> ... </services> <serviceHostingEnvironment aspNetCompatibilityEnabled = "True"/> </system.serviceModel>
<%@ ServiceHost Language = "C#" Debug = "true" CodeBehind = "~/App_Code/MyService.cs" Service = "MyService" Factory = MyServiceFactory %>
<netTcpBinding> <binding name = "ReliableTCP"> <reliableSession enabled = "true"/> </binding> </netTcpBinding>
//All Service Endpoints [DeliveryRequirements(RequireOrderedDelivery = true)] class MyService : IMyContract,IMyOtherContract {...}//Endpoints that expose certain contract [DeliveryRequirements(TargetContract = typeof(IMyContract), RequireOrderedDelivery = true)] class MyService : IMyContract,IMyOtherContract {...}//All services that implement a contract [DeliveryRequirements(RequireOrderedDelivery = true)] [ServiceContract] interface IMyContract {...} April 22
Code Camp Oz is a 'TechEd' for poor man an without advertising. It is .NET developer community-driven event which allows people with interests across the .NET platform to come together in one location and see speakers (including many expert presenters) present on a wide range of developer topics.
Hope to see you there.
I will be presenting @ Office System Forum 2008 - Melbourne Australia. The topic I will be covering is Office Business Applications development using VSTO in VS 2008.
Hope to see you there! April 15 This week I am doing my 'Building SharePoint 2007 Solutions Master Class' in Canberra (ACT Australia). This is an advanced SharePoint course with the prominent SharePoint expert Patrick Tisseghem of u2u. The highlights/notes of today (in addition to the course material): 1) Introduction - SharePoint Site = Virtual File System Stored and Maintained in SQL Server DB.
- SharePoint is strategic Microsoft Product - it is the future OS!
- WSS 3.0 =
- Site Provisioning Engine: Schema defined in CAML + Instances stored in the Content DB
- Core Workspace Services API (Microsoft.SharePoint.dll = more than 9000 Classes!).
- To leverage SharePoint, you can either customize Out of the Box collaboration features (using SharePoint Designer) or extend the platform using .Net (SharePoint = ASP.Net++ = ASP.Net Extensions.
- For better performance, SharePoint workspaces can be organised into:
- Active - short-lived collaboration sites
- Stable - team sites, Department/Enterprise portals
- Archive - less-frequently used content (this could use Records Repository Template).
- Office = Comfort zone for information workers. Hence SharePoint and OBA aims to enhance the experience of existing LOB Apps and make them readily accessible to information workers.
- 1 Farm - 1 Config DB.
- Feature = collection of files to make available/advertise SharePoint items such as Web parts.
- Content DB - Recommended Maximum Size 50GB (practical limitation).
- Web site vs. Web Application:
- Web site live uses unmanaged code and execute in the process server space as the IIS.
- Web App delegates the execution of managed .Net code to w3wp.exe. Request goes through HTTP Handlers pipeline, events are fired and they could be handled in global.asx. e.g., Forbidden access handler when Web.config file is requested. W3wp.exe are managed by App Pool that defines app pool config particularly the Windows account to use by the app pool. When a Web App is created, it needs to be associated with an App Pool. For SharePoint the App Pool Account must have access to Config and Content DB.
- _vti_bin - vti stands for Vermeer Technologies Incorporated, the company that built FrontPage extensions and was bought by Microsoft in 1996.
- _Layout is a fully trusted location (similar to GAC), can run SharePoint code using elevated privileges.
- When a Web App is WSS extended, the standard ASP.Net HttpModules and HttpHandlers are replaced by dedicated SharePoint handlers (i.e., SPHttpModules, SPHttpHandlers). For example HttpModules can be used to address multi-language site requirements (e.g., commercial product: http://www.icefire.ca/).
- For Dev - change Web Config and set CallStack to true and customErrors to Off. Changes to WebConfig can be done programmatically using SPWebConfigModification.
- 2 Web Apps can be used to support Intranet/Internet scenarios with different authentication modes.
- StsAdm is the super tool for admin. It can be extended need to implement ISPStsadmCommand Interface.
2) Site Collections - Site Collection = boundary for configuration, security, backup boundary, etc.
- SharePoint only supports backup and restore at the Site Collection and Site Scope. Better Backup and Restore http://www.avepoint.com/ (e.g., Backup one document library).
- A Web App can have up to 50,000 Site Collection and every Site Collection can have up to 250000 sites. Recommended to limit 2000 Sub-sites under top-level site. Can use Url alias for deeply nested sub-sites.
3) Tools April 14 Last month I was busy doing my SharePoint exams. I am know SharePoint Certified. - Exam 70-541 - WSS 3.0 Application Development is focused on WSS 3.0 Object Model (OM) 80%, Site Definitions 10% and Workflows 10%. Very tricky questions. I used Inside WSS 3.0 book to prepare for the exam. There were questions not covered in the book such as WSS API to navigate the Farm info such as listing the Content Databases. Also there were some tricky questions about alerts.
- Exam 70-542 - MOSS Application Development is focused on BDC concepts and BDC metadata, Audience Targeting API, MembershipManager API, Search API, bit of InfoPth and Excel Services. Relatively easier exam. I used the following resources for the exam:
1) MOSS SDK Visual How-To videos + MOSS SDK code How-Tos 2) SharePoint Conference 2006-2007 Webcats - SharePoint conference http://msdn2.microsoft.com/en-gb/office/aa905380.aspx (has some excellent and in-depth video-casts) & http://technet.microsoft.com/en-au/bb498198.aspx (1) and (2) are all you need to pass this exam. - Exam 70-630 - MOSS 2007 Configuration is focused on Configure MOSS Search, Configure InfoPath Forms, Content Management, bit of BI Config. It was easier exam but I did not find it in-depth enough to assess the skills required for MOSS admin!
I used the following resources for the exam: 1) Microsoft Office SharePoint Server 2007 Administrator's Companion http://www.microsoft.com/MSPress/books/9537.aspx (it is huge book 1155 pages - I only selectively read couple of chapters particularly - Configure server farms and define a farm topology & - Create and manage content libraries, records repositories, and document workflows) 2) SharePoint Conference 2006-2007 Web cats - SharePoint conference http://msdn2.microsoft.com/en-gb/office/aa905380.aspx (has some excellent and in-depth video-casts) & http://technet.microsoft.com/en-au/bb498198.aspx (1) and (2) are all you need to pass this exam. - Exam 70-631 - WSS 3.0 Configuration is focused on WSS Central Admin, Features Deployment, SharePoint Zones, Alternate Access URLs, etc. Quite simple exam, only 41 questions.
Anyway, these exams help me to stay focused and motivated on learning required skills for future engagements. Also they are a great way to get easy exemptions from home duties such as vacuuming :)
|
|
|
|