C# WCF 中的“端点”是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/745212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is an "endpoint" in WCF?
提问by Firoso
I was under the impression that an endpoint was defined in a config file as the list of possible clients but that makes no sense (in the sense that I assumed it said what computers could connet to the service) now I'm gathering that it's more of a definition, so would someone please explain what an end point is to me? I understand the concept of definining the contract interface and then implementing the contract but I get lost somewhere between there and actually having something useable.
我的印象是,端点在配置文件中定义为可能的客户端列表,但这没有意义(从某种意义上说,我假设它说的是哪些计算机可以连接到服务)现在我正在收集它更多一个定义,那么有人可以解释一下我的终点是什么吗?我理解定义合同接口然后实施合同的概念,但我在那里迷路了,实际上有一些可用的东西。
What is an address in this context? the host address?
在这种情况下,地址是什么?主机地址?
A binding is the communications method/protocol to use correct?
绑定是使用正确的通信方法/协议吗?
the contract is the "object being shared" essentially (yes i know that's so technically incorrect but work with me here)
合同本质上是“共享对象”(是的,我知道这在技术上是不正确的,但在这里和我一起工作)
采纳答案by casperOne
An endpoint is what a service exposes, and in WCF terms, is made up of three things:
端点是服务公开的内容,在 WCF 术语中,它由三部分组成:
- Address
- Binding
- Contract
- 地址
- 捆绑
- 合同
Address is the URL by which the endpoint can be reached.
地址是可以到达端点的 URL。
Binding dictates transformations that are applied as well as the shape (to some degree) of the messages sent to the implementation of the Contract at the Address.
绑定指示应用的转换以及发送到地址处的合约实现的消息的形状(在某种程度上)。
Contract dictates what operations are being exposed at the address. It's exactly what it says it is, it's a contract to indicate what calls are permissible.
合同规定了在地址处公开的操作。这正是它所说的,它是一份合同,表明哪些电话是允许的。
Most of the time, people remember it as A B C.
大多数时候,人们记得它是 AB C。
Some things to note:
一些注意事项:
The binding is typically going to be a combination of channels with behaviors applied; channels being elements on the channel stack which modify the message and perform actions before they get to the service implementation.
绑定通常是应用行为的通道组合;通道是通道堆栈上的元素,它们在到达服务实现之前修改消息并执行操作。
While commonly represented by an interface in .NET, it is not a requirement that a Contract be represented in this manner. Some design-first advocates will define the schemas to the messages that are going to be sent for the request and the response first, which is what WCF transforms the .NET Contract interface into.
虽然通常由 .NET 中的接口表示,但不要求以这种方式表示合同。一些设计优先的倡导者将首先定义为请求和响应发送的消息的模式,这就是 WCF 将 .NET Contract 接口转换成的内容。
回答by Otávio Décio
回答by draconis
I'm going to cite Juval Lowy's Programming WCF Serviceshere:
我将在这里引用 Juval Lowy 的Programming WCF Services:
Every service is associated with an address that defines where the service is, a binding that defines how to communicate with the service, and a contract that defines what the service does. This triumvirate governing the service is easy to remember as the ABC of the service.
WCF formalizes this relationship in the form of an endpoint. The endpoint is the fusion of the address, contract, and binding.
Every endpoint must have all three elements, and the host exposes the endpoint.
每个服务都与定义服务所在位置的地址、定义如何与服务通信的绑定以及定义服务做什么的契约相关联。这种管理服务的三人组很容易被记住,因为它是服务的 ABC。
WCF 以端点的形式形式化了这种关系。端点是地址、合约和绑定的融合。
每个端点都必须具有所有三个元素,并且主机公开端点。
回答by draconis
A Service Endpoint has an Address, a Binding, and a Contract. The Endpoint's Address is a network address where the Endpoint resides. The EndpointAddress class represents a WCF Endpoint Address. The Endpoint's Binding specifies how the Endpoint communicates with the world including things like transport protocol (e.g., TCP, HTTP), encoding (e.g., text, binary), and security requirements (e.g., SSL, SOAP message security). The Binding class represents a WCF Binding. The Endpoint's Contract specifies what the Endpoint communicates and is essentially a collection of messages organized in operations that have basic Message Exchange Patterns (MEPs) such as one-way, duplex, and request/reply. The ContractDescription class represents a WCF Contract.
服务端点具有地址、绑定和合同。端点地址是端点所在的网络地址。EndpointAddress 类表示 WCF 端点地址。端点的绑定指定端点如何与世界通信,包括传输协议(例如,TCP、HTTP)、编码(例如,文本、二进制)和安全要求(例如,SSL、SOAP 消息安全性)。Binding 类表示 WCF 绑定。Endpoint's Contract 指定 Endpoint 通信的内容,本质上是一组按操作组织的消息,这些操作具有基本的消息交换模式 (MEP),例如单向、双工和请求/回复。ContractDescription 类表示 WCF 合同。
回答by sdd
A Service Endpoint has an Address, a Binding, and a Contract. The Endpoint's Address is a network address where the Endpoint resides. The EndpointAddress class represents a WCF Endpoint Address. The Endpoint's Binding specifies how the Endpoint communicates with the world including things like transport protocol (e.g., TCP, HTTP), encoding (e.g., text, binary), and security requirements (e.g., SSL, SOAP message security). The Binding class represents a WCF Binding. The Endpoint's Contract specifies what the Endpoint communicates and is essentially a collection of messages organized in operations that have basic Message Exchange Patterns (MEPs) such as one-way, duplex, and request/reply. The ContractDescription class represents a WCF Contract.
服务端点具有地址、绑定和合同。端点地址是端点所在的网络地址。EndpointAddress 类表示 WCF 端点地址。端点的绑定指定端点如何与世界通信,包括传输协议(例如,TCP、HTTP)、编码(例如,文本、二进制)和安全要求(例如,SSL、SOAP 消息安全性)。Binding 类表示 WCF 绑定。Endpoint's Contract 指定 Endpoint 通信的内容,本质上是一组按操作组织的消息,这些操作具有基本的消息交换模式 (MEP),例如单向、双工和请求/回复。ContractDescription 类表示 WCF 合同。
回答by DOTNET Team
Endpoints in WCF
WCF Service is a program that exposes a collection of Endpoints. Each Endpoint is a portal for communicating with the world.
End point consists of three components.
1) Address:
Defines where a service is located
ex - http://www.test.com:8001/MyService
2) Bindings:
A binding that specifies how a client can communicate with the endpoint.
ex - BasicHttpBinding,WSHttpBinding,WSDualHttpBinding etc
3) Contracts:
A contract that identifies the operations available
WCF 中的端点
WCF 服务是一个公开端点集合的程序。每个端点都是与世界交流的门户。终点由三个部分组成。
1)地址:
定义服务所在的位置,
例如http://www.test.com:8001/MyService
2)绑定:
指定客户端如何与端点通信的绑定。
例如 - BasicHttpBinding、WSHttpBinding、WSDualHttpBinding 等
3)合同:
标识可用操作的合同
Endpoints will be mentioned in the web.config file on the created service.
端点将在所创建服务的 web.config 文件中提及。
回答by SRJTester
A web service endpoint can hide some or all of these. And based on request can decide internally the processing of Request.
Web 服务端点可以隐藏其中的部分或全部。并且根据请求可以在内部决定请求的处理。
SRJTester tool (available on Github) is nice to specify Endpoint, Actions, protocols etc. while making a service request.
SRJTester 工具(可在 Github 上获得)非常适合在发出服务请求时指定端点、操作、协议等。