0
votes

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

2 Answers

1
votes

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).

2
votes

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