WCF框架为终结点定义了一个专门的ServiceEndpoint类,被定义在System.ServiceModel.Description命名空间中。ServiceEndpoint类包含了EndpointAddress,Binding,ContractDescription三个类型的属性,分别对应Endpoint的Address,Binding,Contract,如下图:
创新互联云计算的互联网服务提供商,拥有超过13年的服务器租用、四川电信机房托管、云服务器、雅安服务器托管、网站系统开发经验,已先后获得国家工业和信息化部颁发的互联网数据中心业务许可证。专业提供云主机、雅安服务器托管、域名注册、VPS主机、云服务器、香港云服务器、免备案服务器等。
要获取服务的终结点,可以通过抽象类MetadataImporter获取,类的定义如下:
- public abstract class MetadataImporter
- {
- public abstract Collection
ImportAllContracts(); - public abstract ServiceEndpointCollection ImportAllEndpoints();
- 其它方法略;
- }
在WCF框架中,最重要的一个方法是ImportAllEndpoints(),WCF框架能够获取服务的所有终结点,并返回一个ServiceEndpointCollection类型的对象。该WCF框架为一个终结点集合,可以通过调用ServiceEndpointCollection的Find()方法或FindAll()方法,找到符合条件的一个或多个终结点。它的定义如下:
- public class ServiceEndpointCollection : Collection
- {
- public ServiceEndpoint Find(Type contractType);
- public ServiceEndpoint Find(Uri address);
- public Collection
FindAll(Type contractType); - 其它成员略
- }