I have a WCF service running locally hosted by a windows service on machine A.
I have an ASP.NET application hosted in IIS on machine B.
My question is this, if I run the ASP.NET application via a browser on machine A, will it be able to consume the local WCF service?
Yes, as long as your configuration is valid, it doesn’t matter where on which server the service is used.
And yes – the client will all have to use the same config – you basically need to specify the “ABC’s of WCF” – address, binding (and possibly binding configuration) and contract – the WHERE, HOW and WHAT of your service.
You can share a lot of the config – especially binding configurations – between server and client with this method: externalize certain parts of the config.
In your server, have something like:
and then in your
bindings.configfile, define:That way, you can copy that file
bindings.configto the clients, and reference it from the client’s config file, too – sharing the same information and making sure it’s the same and up to date on both ends of the communication.This also works for any other of the subsections under
<system.serviceModel>(like behaviors, extensions and so forth).