ASP.NET, WCF: ASP.NET application consuming WCF service hosted in a local windows service
I have a WCF service running locally hosted by a windows service on machine A.
I have an ASP.NET application 开发者_JS百科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?
As long as the address of the service used in the page points to machine A, you should be fine.
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).
精彩评论