首页 数据库 mysql教程 WCF 4 Step By Step Chapter 1,2 Note

WCF 4 Step By Step Chapter 1,2 Note

Jun 07, 2016 pm 03:44 PM
Note step

How Does a WCF Service Work? A host application must perform several tasks, whichinclude: || Starting and stopping the service || Listening for requests from a client application anddirecting them to the service || Sending any responses fr

How Does a WCF Service Work?

A host application must perform several tasks, whichinclude:

|| Starting and stopping the service

|| Listening for requests from a client application anddirecting them to the service

|| Sending any responses from the service back to the clientapplications

 

Service Endpoints      

            -The address of the service

            -The binding supported by the service

                        -Thetransport protocol

                                    -ifyou are using IIS to host the service, you should specify

the HTTP or HTTPS transport protocol. WCF also has built-insupport for the TCP

protocol, named-pipes, and message queues.

                        -The encoding format of messages

                                    -Inmany cases, request and response messages will be transmitted in XML format, encoded as ordinary text.However, in some

cases you might need to transmit data using a binaryencoding, especially if you are transmitting images or handling streams

                        -The security requirements of the service

                                    -Youcan implement security at the transport level and at the message level

                        -The transactional requirements of the service

                        -The reliability of communications with the service

                                    -Networksare notoriously unreliable and can fail at any time.

            -The contract implemented by the service.


Processing a Client Request

The WCF runtime environment for a client application and a service provides acollection of channel objects that can perform this processing for you.

A channel is responsible for handling one aspect of message processing, as specified by the bindings of a service

The WCF runtime composes channels into a channel stack.All messages passing between the client and the service go through each channel in the channel stack. Each channel in the channel stack transforms the message in some way, and the output from one channel is passed as input to the next

the host application must ensure that messages being sent between the client and service conform to the security, reliability, and transactional requirements of the binding being used. When you start a service running, theWCF runtime uses the endpoint information specified as part of the service configuration andcreates alistener object for each address specified for the service. When an incoming request is received, theWCF runtimeconstructs a channel stack by using the binding information specified for the address and routes the incoming data from the client through the stack. If a message successfully traverses all the channels in the
channel stack, the transformed request is passed to an instance of the service for processing.

WCF service must be able to handle requests from multiple client applications simultaneously.To do this, the WCF runtime can createmultiple concurrent
instances of a service
.The WCF runtime creates an InstanceContext object to control the interaction between the channel stack and a service instance


WAS (Windows Process Activation Service )

The Windows Process Activation Service (WAS) extends the functionality of IIS by removing the dependency on the HTTP protocol. Using WAS, you can host services that make use of other protocols, such as TCP, named pipes, and Microsoft Message Queues.


Windows Server AppFabric

If you are hosting WCF services by using IIS or WAS in a production environment, you might want to consider implementing Windows Server AppFabric.

Windows Server AppFabric is a set of extensions to the Windows operating system aimed at making it easier for developers to build faster, scalable, and more-easily managed services.AppFabric provides adistributed in-memory caching service and replication technology that helps developers improve the speed and availability of ASP.NET Web applications and WCF services. AppFabric also includes hosting features that can simplify the deployment, monitoring, and management of services by making use of familiar tools such as PowerShell, Internet Information Services Manager, and Microsoft System Center.


Hosting a Service in a User Application
If you are building your own host application rather than using IIS or WAS, you can achieve most of these tasks by using theServiceHostclass, available in the
System.ServiceModel namespace. Opening a ServiceHost object causes the WCF runtime to examine the binding configuration for each endpoint of the service and start listening on each endpoint address.

productsServiceHost.Open();
登录后复制


Host service in User Application vs. IIS or WAS
Previously, when you hosted the service in IIS and WAS, you did not need to provide an endpoint definition in the configuration file.This was because the WCF runtime could deduce default values for each of the items that constituted the endpoint; the address was determined by concatenating the name of the .svc file to the virtual folder holding the service,the binding was assumed to be basic HTTP, and the service defined only a single service contract. When you build a custom host application, these assumptions are no longer valid,so you must specify them in the configuration file.

IIS or WAS

WCF 4 Step By Step Chapter 1,2 Note


Deploying a WCF Service in IIS Without an .svc File

The .svc file is a special content file that IIS uses to recognize a WCF service. It provides the information that the hosting environment in IIS uses to activate the WCF run time and start the service.

WCF 4.0 provides a feature called Configuration-Based Activation, with which you can combine the information normally included in the .svc file directly into the Web.config
file for a WCF service hosted by IIS.


<system.servicemodel>
    <behaviors>
      <servicebehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <servicemetadata httpgetenabled="true"></servicemetadata>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <servicedebug includeexceptiondetailinfaults="false"></servicedebug>
        </behavior>
      </servicebehaviors>
    </behaviors>
    <servicehostingenvironment multiplesitebindingsenabled="true">
      <serviceactivations>
        <add relativeaddress="NoServiceFile.svc" service="ProductsServiceImpl"></add>
        </serviceactivations>
      </servicehostingenvironment>
  </system.servicemodel>
登录后复制


Understanding Endpoints and Bindings

An endpoint specifies the point of contact for a service; it provides the address that the service listens to, the binding that the client must use to connect to the service,
and the contract that defines the functionality exposed by the service. This is the information that a client application must specify to successfully connect to the service.

A binding element corresponds to a channel. Remember that when a host opens a service, the WCF runtime uses each binding element in the binding
configuration to create the channel stack.A client also creates a channel stackwhen it connects to the serviceby opening a proxy object. To ensure that a client application can communicate successfully with a service, it should use a binding configuration that provides binding elements that match those implemented by the service.


WCF 4 Step By Step Chapter 1,2 Note

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

如何使用Alter Table语句在MySQL中更改表? 如何使用Alter Table语句在MySQL中更改表? Mar 19, 2025 pm 03:51 PM

本文讨论了使用MySQL的Alter Table语句修改表,包括添加/删除列,重命名表/列以及更改列数据类型。

如何为MySQL连接配置SSL/TLS加密? 如何为MySQL连接配置SSL/TLS加密? Mar 18, 2025 pm 12:01 PM

文章讨论了为MySQL配置SSL/TLS加密,包括证书生成和验证。主要问题是使用自签名证书的安全含义。[角色计数:159]

您如何处理MySQL中的大型数据集? 您如何处理MySQL中的大型数据集? Mar 21, 2025 pm 12:15 PM

文章讨论了处理MySQL中大型数据集的策略,包括分区,碎片,索引和查询优化。

哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么? 哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么? Mar 21, 2025 pm 06:28 PM

文章讨论了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比较了它们对初学者和高级用户的功能和适合性。[159个字符]

如何使用Drop Table语句将表放入MySQL中? 如何使用Drop Table语句将表放入MySQL中? Mar 19, 2025 pm 03:52 PM

本文讨论了使用Drop Table语句在MySQL中放下表,并强调了预防措施和风险。它强调,没有备份,该动作是不可逆转的,详细介绍了恢复方法和潜在的生产环境危害。

说明InnoDB全文搜索功能。 说明InnoDB全文搜索功能。 Apr 02, 2025 pm 06:09 PM

InnoDB的全文搜索功能非常强大,能够显着提高数据库查询效率和处理大量文本数据的能力。 1)InnoDB通过倒排索引实现全文搜索,支持基本和高级搜索查询。 2)使用MATCH和AGAINST关键字进行搜索,支持布尔模式和短语搜索。 3)优化方法包括使用分词技术、定期重建索引和调整缓存大小,以提升性能和准确性。

您如何用外国钥匙代表关系? 您如何用外国钥匙代表关系? Mar 19, 2025 pm 03:48 PM

文章讨论了使用外国密钥来代表数据库中的关系,重点是最佳实践,数据完整性和避免的常见陷阱。

如何在JSON列上创建索引? 如何在JSON列上创建索引? Mar 21, 2025 pm 12:13 PM

本文讨论了在PostgreSQL,MySQL和MongoDB等各个数据库中的JSON列上创建索引,以增强查询性能。它解释了索引特定的JSON路径的语法和好处,并列出了支持的数据库系统。

See all articles