Reputation: 1685
I am trying to connect to a URI pointing to a WSDL file which describes a WCF service by using the MetadataExchangeClient class.
var mexClient = new MetadataExchangeClient(uri, MetadataExchangeClientMode.HttpGet);
var metaDocs = mexClient.GetMetadata();
The problem is that I cannot access this uri directly and need to go through a HTTP proxy server. The proxy server URL can change at runtime so I cannot simply configure it through the app.config file.
Where can I specify the proxy server information in the MetadataExchangeClient class?
Anyone got an idea? WCF experts?
Upvotes: 2
Views: 868
Reputation: 12540
You can override the GetChannelFactory and provide an implementation that can create a suitable endpoint i.e. a BasicHtppBinding with the proxy details added.
See here for a clue to how programmatically set Binding.
See here for starting point on creating the Channel Factory (see the 3 comments at the end of the post)
This shows how to use MetadataExchangeClient with a Custom Binding:
Here's the .NET Framework Source to MetadataExchangeClient so you can get a better understanding of what it is doing.
Upvotes: 0
Reputation: 7817
You need to specify the proxy in the app.config
like this:
<system.net>
<defaultProxy enabled="true">
<proxy bypassonlocal="true"
proxyaddress="http://proxy.domain.org:8888/" />
</defaultProxy>
</system.net>
Upvotes: 3