How to define the LocalEndPoint to use by a WCF client when calling a WCF service (if the client machine has multiple IP addresses) ?
I have a machine located in a DMZ with two IP addresses, the external IP address can be reached through the firewall via a VPN connection from our webserver, located at an external service provider. On this machine runs a WCF and Unity-based custom app server, which should act as proxy or application level gateway (ALG). It shall accept the service calls from the web server and uses a wcf client factory to regenerate the service calls, forwarding them to the real app server in the LAN.
When re-creating the service calls on this proxy using a wcf client factory, the wcf client should use the second, internal IP address of this machine, because only messages coming from this internal IP address will be allowed to pass the firewall to reach the app server in the LAN. Unfortunately our wcf client proxies always choose to create the outgoing messages using the first, "external" IP addresses. I am looking for a way to explicitly setting the IP address to use by the wcf client proxies.
I could find only one WCF binding element that allows the definition of a LocalEndPoint or ClientBaseAddress: CompositeDuplexBindingElement. As far as I understand from the documentation this property is meant to tell the server where to send the asynch reply messages, so it's a different setting than what I am looking for.
Any Idea what I can do to come to a workable solution?
Thanks in advance for any helpful advice!!
This seems to be a similar question, just using TcpClient/Sockets instead of WCF: http://stackoverflow.com/questions/2016012/specify-the-outgoing-ip-address-to-use-with-tcpclient-socket-in-c
And another one, this time regarding a SoapClient: http://stackoverflow.com/questions/321788/c-binding-a-new-soapclient-to-a-specific-ip-address-before-sending-outgoing-req