views:

40

answers:

2

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?

+2  A: 

As long as the address of the service used in the page points to machine A, you should be fine.

taylonr
Another question, will we have to store the WCF configuration in web.config and will this mean that all web clients will have to share the same configuration? The aim is to have a number of clients all running with this setup. Im just not quite sure how to handle the configuration for this scenario.
Andrew
You can store multiple bindings etc in your web.config file.
taylonr
+1  A: 

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:

<system.serviceModel>
   <bindings configSource="bindings.config" />
</system.serviceModel>

and then in your bindings.config file, define:

<bindings>
  <basicHttpBinding>
     <binding name="BasicNoSecurity">
         <security mode="None" />
     </binding>
  </basicHttpBinding>
</bindings>

That way, you can copy that file bindings.config to 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).

marc_s