WCF provides invalid urls in wsdl behind load balancer

I have wcf installed on a cluster of web servers behind a load balancer.

The public address is http: //externaldomain/mywcf.svc , and this is a unique endpoint that users should have access to.

So when I paste this url in my browser to see the "helper page" (the page where it shows me the url of its "wsdl" file) the address is not what I expect: " http: // externaldomain / mywcf.svc? wsdl "but" http: //server1/mywcf.svc? wsdl "(server1 is the name of the server that wcf is running on and the user was redirected by the load balancer)

this makes it impossible to add services in visualstudio because the suggested address http: //server1/mywcf.svc=wsdl "is a private url

So how do I configure the wcf options to make it "aspnet" to create a helper page with the "correct" URL? is there some kind of "proxy" node or something similar set in web.config

  #### public url ####           #### private url ####

                                (http://server1)
                                 ----------------
                            -->  -- webserver1 --
                           /     ----------------
                          /
 (http://externaldomain) /
 ---------------------- /
 --- load balancer ---- 
 ---------------------- \
                         \
                          \
                           \     (http://server2)
                            -->  ----------------
                                 -- webserver2 --
                                 ----------------

      

+3


source to share


1 answer


WCF has special behavior for such cases useRequestHeadersForMetadataAddress

.

<serviceBehaviors>

  <behavior>

    <useRequestHeadersForMetadataAddress/>

  </behavior>

</serviceBehaviors>

      



This behavior causes the service to replace URLs with the URL used in the request, so it avoids the problem you mentioned. More information: http://zamd.net/wcf/2010/01/14/using-request-headers-for-metadata-address.html

+2


source







All Articles