开发者

WCF mex does not contain the complete binding information from the host

I'm publishing a service with a MEX endpoint for metadata exchange and I'm using the code below to discov开发者_如何学Pythoner 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.


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:

  • service contract / service methods
  • parameters needed for those service methods
  • data type declarations in XML schema for the data types used
  • additional service related information like bindings used etc.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜