+3  A: 

You might try decorating your service class with:

[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
Mitch Baker
+1  A: 

I don't know about the solution from Mitch Baker, never tried it. But this involves modifying the generated code. There is another way to get around that.

I assume that you generated client code using svcutil.exe, giving a MEX address that points to the firewall. When you do this, all the configuration needed is added to the App.config (or Web.config). However, the service's address in the configuration will point to the real service address (as in the WSDL file the address of the service sill be the real service's address).

So, what I think will solve this issue:

  1. Generate client code by giving the MEX address (eg: http://:Port-X/service/wcfservice.svc?wsdl). This will generated all the needed configuration.

  2. When invoking the client constructor, give the URI of the firewall as the EnpointAddress, and the configuration name of the generated configuration. This way, the client will send a message as if it was sending it to the service, but to the firewall's address:

    client = new ServiceClient(endpointConfigName, new System.ServiceModel.EndpointAddress("http://:Port-X/service/wcfservice.svc"));

Philippe
A: 

Mitch's solution worked well, I will try Philippe's out of curiosity XD.

Many thanks to both!

Cheers

Marko
+2  A: 

A safer way to handle this is to set the endpoint ListenUri to the service Url, and the endpoint Address to the external endpoint where clients send messages. This way the service "trusts" messages directed only to that address, not just ANY address.

Michele Leroux Bustamante