views:

158

answers:

2

I'm trying to help a customer interop w/ a PHP client but we have a load balancer that is in front of the IIS farm. Because of this when you actually view the .svc?wsdl you get specific server listed inside this WSDL. Then when my customer is trying to generate a client using something like so

$client = new SupplierService();

They get a timeout for a specific server in the farm (not the uri we gave them that points to the load balancer itself)

I have even flatted the WSDL by hand, generated a .net client using svcutil to prove that this WSDL should be enough to get a valid call through the load balancer (and the .net client does work using this flat WSDL generated client)

After I got this working I emailed the client this flat WSDL file to generate a valid php client from it (not the uri that was causing issues) and it just hangs. With no error message or exception to go from ...

Also when I watch the actual message come across using Wireshark the .net and php client SOAP data looks almost identical. yet the .net client works and the php client hangs w/ no error thrown back to the client or logged via .NET

Anything I might have missed here or should be aware of when doing interop w/ WCF behind a load balancer?

+1  A: 

In situations where you're balanced behind a balancer like this, if you want have the correct server name emitted in the WSDL you need to actually add the <host> section to your service configuration like so:

<service ...>
    <host>
        <baseAddresses>
            <add baseAddress="http://subdomain.yourexternaldns.com" />
            <add baseAddress="https://subbomain.yourexternaldns.com" />
        </baseAddresses>
    </host>
</service>

You also need to make sure you've configured host headers in IIS for this to work and that your blancer is passing through the host header untouched.

Drew Marsh
Can you explain the host section in a little more detail? This is something I will add in the web.config for my WCF service or ? Also the actual base address needs to be the root uri of each individual server or do I just have 1 base address listed (the uri the is the load balancer) ?
Toran Billups
Sure, you just add it to your WCF service hosts .config (i.e. web.config if ASP.NET, AppName.config if self-hosted) and then just make the changes to IIS I mentioned on all servers where the app will run.
Drew Marsh
Ooops, didn't answer your second question. You just put the address through which your service is accessed publicly, so, yes, the one that the balancer is managing. Note you have to add one for each supported protocol, hence why I have the http and https ones there.
Drew Marsh
So in my case I have 1 load balanced uri but 2 servers on the farm behind it. In my host setup like above I will only have 1 base address listed then (the uri for the load balancer) or 2 base addresses listed (1 per server on the farm) ? Thanks again for the help!
Toran Billups
Just one. The number of servers in the farm does not play into this at all. All you're trying to do is say: "Whatever machine this is running on right now, this is the logical address where I'm actually exposing this service.".
Drew Marsh
Great explanation - I added the uri for the load balancer as the host base address! I'll keep working w/ the php client to get this up and running!
Toran Billups
A: 

There are a few things you could try:

  • Test the php client directly against the service to verify if the load balancer is the problem or not.
  • Check the IIS and event logs on the machine running the WCF Service
Shiraz Bhaiji