Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2010, 07:49 AM
Rajeev Rajput
Guest
 
Posts: n/a
Default WCF Mex Address

I am new to WCF. I was exploring Mex address in WCF,I would appreciate if somebody through the light on Using Mex address in WCF in detail.

I read from one of the blog that it is used when channel is not using HTTP for communication.

If sombody could come up with a real time use of Mex address than it would be a great help!

Thanks.
 
Old July 15th, 2010, 07:17 AM
Authorized User
 
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default It Could Be Helpful For You Rajeev

Hi Rajeev,

Adding MEX endpoints programmatic:-
Like any other endpoint, you can only add a meta data exchange endpoint programmatically before opening the host. WCF does not offer a dedicated binding type for the meta data exchange endpoint. Instead, you need to construct a custom binding that uses the matching transport binding element, and then provide that binding element as a construction parameter to an instance of a custom binding. Finally, call the AddServiceEndpoint( ) method of the host providing it with the address, the custom binding, and the IMetadataExchangecontract type. Example shows the code required to add a MEX endpoint over TCP. Note that before adding the endpoint you must verify the presence of the metadata behavior.
Adding TCP MEX endpoint programmatically
BindingElement bindingElement =
new TcpTransportBindingElement( );
CustomBinding binding =
new CustomBinding(bindingElement);
Uri tcpBaseAddress =
new Uri("net.tcp://localhost:9000/");
ServiceHost host =
new ServiceHost(typeof(MyService),tcpBaseAddress);
ServiceMetadataBehavior metadataBehavior;
metadataBehavior =
host.Description.Behaviors.
Find<ServiceMetadataBehavior>( );
if(metadataBehavior == null)
{
metadataBehavior = new ServiceMetadataBehavior( );
host.Description.Behaviors.Add(metadataBehavior);
}
host.AddServiceEndpoint(
typeof(IMetadataExchange),binding,"MEX");
host.Open( );



Thanks
Ankit
Daccit Pvt Ltd
 
Old August 24th, 2010, 07:39 AM
Registered User
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mex address

Thanks Ankit, this is a good example how to use mex address. The question I am looking for why I need mex address, what benifit it provide over regular end point. If I remove mex address from my config , will my end point will make my application still work. Sorry for late reply.

Thanks.





Similar Threads
Thread Thread Starter Forum Replies Last Post
wcf help!!! marino .NET Framework 3.5 0 March 24th, 2010 11:37 AM
WCF Bindings johnlorford Windows Communication Foundation 1 October 15th, 2009 04:55 AM
WCF yangqingyue1985 C# 0 July 28th, 2008 02:17 AM
WCF endpoint error when wrapping WCF service with jdawg1979 Visual Studio 2008 0 July 8th, 2008 11:56 AM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.