Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of WCF Open Source Zone

Shulou Source: shulou.com Published: 2022-06-02 06:41:39 10月01日 Update

This article mainly explains the "WCF open source zone example analysis", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "WCF open source zone example analysis" bar!

Prepare:

1. Install .NET Framework 3.5 Beta 2.

At first I installed the .NET Framework 3.5 June 2007 Community Technology Preview (CTP), which took some detours.

2. Install Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF).

3. Check whether IIS has a mapping from .svc to c:\ windows\ microsoft.net\ framework\ v2.0.50727\ aspnet_isapi.dll. If not, establish the mapping and cancel the selection of "check whether the file exists".

Start:

1. Create a new Web Site project in VS 2005.

Add web.config and change to.

2. Add a WCFService to the project, named CNBlogsWCFService.svc. 3. Modify the code of CNBlogsWCFService.cs in App_Code:

Code for CNBlogsWCFService.cs: [ServiceContract (Namespace = "http://www.cnblog.com/")] public interface ICNBlogsWCFService {[OperationContract] string AddToFavorites (string blogID, string postID);} public class CNBlogsWCFService: ICNBlogsWCFService {public string AddToFavorites (string blogID, string postID) {return string.Format (" Collection successful! BlogID: {0}, PostID: {1} ", blogID, postID);}}

3\ if you want to learn more about WCF open source code, please refer to:

Artech: [original] my trip to WCF (1): create a simple WCF program

Getting started with Bruce Zhang:Windows Communication Foundation (Part Two)

4. Modify the code of CNBlogsWCFService.svc:

Added: Factory= "System.ServiceModel.Activation.WebScriptServiceHostFactory.

Change to:

Factory is added in .NET Framework 3.5 Beta 2, and we use Visual Studio 2005 extensions for .NET Framework 3.0, so add it manually.

If you do not call WCF through Ajax, you need to set it to: Factory= "System.ServiceModel.Web.WebServiceHostFactory".

5. Start * times and visit http://localhost/AjaxWCFDemo/CNBlogsWCFService.svc, and the following page will appear:

6. Continue to run, visit http://localhost/AjaxWCFDemo/CNBlogsWCFService.svc/js, and you will see the client agent script that is automatically generated to access WCF.

7 、 OK! The server-side WCF is ready, so let's start the client-side access.

8. Configure ASP.NET Ajax, and set WCF open source in web.config:

Tags: Zone analysis code learning content client end project preparation inspection run success trip client that is detours ideas situations manual files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Redmi Shulou Information Apple vpn