WCF mex 不包含来自主机的完整绑定信息
我正在发布一个带有用于元数据交换的 MEX 端点的服务,并且我使用下面的代码来发现它并获取元数据信息
DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
FindCriteria findCriteria = FindCriteria.CreateMetadataExchangeEndpointCriteria(ContractType);
findCriteria.Duration = TimeSpan.FromSeconds(15);
findCriteria.MaxResults = 1;// MaxResults;
FindResponse result = discoveryClient.Find(findCriteria);
discoveryClient.Close();
ServiceEndpointCollection eps = MetadataResolver.Resolve(ContractType, result.Endpoints[0].Address);
return eps[0].Binding;
当我在客户端中获取元数据信息时,绑定信息 (OpenTimeout
, ReceiveTimeout
和 SendTimeout
)恢复为默认值。
这是主机中的绑定信息
<binding name="MyServiceBinding" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="23:50:00" sendTimeout="00:05:00" maxReceivedMessageSize="50000000">
<readerQuotas maxStringContentLength="50000000" maxArrayLength="50000000" />
<reliableSession ordered="true" inactivityTimeout="00:01:00" enabled="false" />
<security mode="None" />
</binding>
,这是我发现的另一个问题,与我的问题几乎相同。
我想知道我是否做错了什么或者我是否误解了元数据交换的概念。
我想做的是将所有必要的信息发送给我的客户,以便他们可以自行自动配置,并且没有任何硬代码配置。
I'm publishing a service with a MEX endpoint for metadata exchange and I'm using the code below to discover it and get the metadata information
DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
FindCriteria findCriteria = FindCriteria.CreateMetadataExchangeEndpointCriteria(ContractType);
findCriteria.Duration = TimeSpan.FromSeconds(15);
findCriteria.MaxResults = 1;// MaxResults;
FindResponse result = discoveryClient.Find(findCriteria);
discoveryClient.Close();
ServiceEndpointCollection eps = MetadataResolver.Resolve(ContractType, result.Endpoints[0].Address);
return eps[0].Binding;
When I get the metadata information in my client the binding information (OpenTimeout
,ReceiveTimeout
and SendTimeout
) is back to its default values.
Here is the binding information in the host
<binding name="MyServiceBinding" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="23:50:00" sendTimeout="00:05:00" maxReceivedMessageSize="50000000">
<readerQuotas maxStringContentLength="50000000" maxArrayLength="50000000" />
<reliableSession ordered="true" inactivityTimeout="00:01:00" enabled="false" />
<security mode="None" />
</binding>
here is another question i've found that is almost the same as mine.
WCF Service Binding taking default values instead of custom values
I would like to know if I'm doing something wrong or if I misunderstood the concept of metadata exchange.
What I'm trying to do is send all the info necessary to my clients so they can auto config them self and do not have any hard code configuration.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为你做错了什么——你只是对元数据交换期望过高。
MEX 的目的是能够以编程方式发现新服务,并为这些服务创建客户端代理。为此,有 WSDL - 基本上 WSDL 中包含的任何内容都是元数据交换的一部分:
MEX 不包含所有 WCF 特定配置设置 - 这是您所发现的。 MEX 将创建一个有效的客户端代理 - 但它从未打算将所有配置设置从服务器传输到客户端。您需要在客户端自己手动编写代码。
I don't think you're doing anything wrong - you're just expecting too much from the metadata exchange.
The purpose of MEX is to be able to discover new services programmatically, and create client-side proxies for those services. For this, there's the WSDL - basically anything contained in the WSDL is part of the metadata exchange:
But MEX does not contain all WCF specific configuration settings - which is what you've discovered. MEX will create a functioning client-side proxy - but it never had the intention of transporting all configuration settings from the server to the client. You'll need to hand-code this yourself, on the client side.