Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of WCF Open Source Zone

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report