Silverlight WCF services: WCF is accessed through Client?
Does a WCF service get called from the IIS server hosting the silverlight XAP or directly from the client's browser? If you were to put your WCF services on a server closer to your database (and not the same server as your Silverlight / ASP.NET page), would the WCF server's ports need to be opened to the world?
It may be sound like a simple answer, but really it's not as obvious as it sounds for example:
- ClientAccessPolicy.xml
This file helps you control which domains have access to call you开发者_运维技巧r WCF service. Here is a very basic example of how you can restrict access to only those applications running under your desired domain. This permits someone running your Silverlight application from both a secure and a non-secure url.
<?xml version="1.0" encoding="utf-8"?> <access-policy> <cross-domain-access> <policy> <allow-from http-request-headers="*"> <domain uri="https://www.yourwebsite.com"/> <domain uri="http://www.yourwebsite.com"/> </allow-from> <grant-to> <resource path="/" include-subpaths="true"/> </grant-to> </policy> </cross-domain-access> </access-policy>
Sounds as if the call goes back to the web server which hosts the Silverlight application and then to the WCF service.
Additional: I understand that I may not have communicated my question well.
If you have a server that you use for your WCF server (Server A) and a server hosting your Silverlight application (Server B)
Does your client directly call Server A or does it make a request to Server B which is used as a proxy to communicate with Server A?
Server A is on one domain, Server B is on another domain, and Client is through the internet.
In silverlight, the silverlight app runs completely in the context of the browser. The only communication allowed in a normal, internet deployed silverlight app is via services.
It's still nice to have the WCF service as close to the database as possible, but that has nothing to do with the silverlight part of the scenario.
Silverlight can't host services, even in-proc, at least not as far as I'm aware. Your service will be hosted in IIS alongside the ASP.NET application which probably hosts your Silverlight tag.
Regarding where you place your service, unless you have good reason to believe it belongs on the database server, don't do it. I would liken this to writing stored procs with business logic because you're concerned with the amount of data being transferred from your database - it's usually something you resort to when you have an actual need, not a hypothetical one.
Even if this is something you wish to do, consider that the data will always have to go through your application server.
精彩评论