WCF, Silverlight: clientaccesspolicy.xml not being found - wcf

I"m trying to connect my Silverlight application to a WCF service that I'm hosting myself. I've created a clientaccesspolicy.xml file, and placed it in the service host project's root, but when I try to hit the service, my http sniffer says it can't be found. Specifically the file it's looking for is http://localhost:8080/clientaccesspolicy.xml.
I'm running the server and the silverlight app in debug mode in Visual Studio 2010. Do I need to put the file somewhere else?

The clientaccesspolicy.xml file must be in the root of the domain where the service is hosted. You may already have it there but the virtual path of the web site or web application from the property page will need to be changed to "/"
See this page
for more information.

I did not understand how you're hosting your WCF service?
Is it hosted in a asp.net application or a windows host (self-hosting)? If the latter is the case, you may have to implement a clientaccesspolicy service that provides the content of the clientaccesspolicy.xml file on request.
For example like this.

Related

Host WCF web service in IIS

I've created a web service, and I hosted in IIS, it worked perfectly.
But when setting up a website in IIS, there's a field to bind the physical path to the WCF project folder
My question is what file in that folder are needed for IIS to host the service?
Because I need to create websites in clients' server, so I don't want my code to be seen.
Thanks

Directory access outside of wwwroot for a WCF service hosted on IIS

I've been working on a WCF service that is currently hosted on IIS. I need to get the WCF service to access a directory outside of the wwwroot folder.
Am I right in assuming that directory access outside of wwwroot is restricted to WCF apps hosted on IIS as it would be restricted for an ASP.Net application hosted on IIS?
If this is the case, what is the safest way of allowing the WCF service to acccess a set folder outside of the wwwroot?
BTW - I'm running in Mixed Transports Mode, not ASP.Net compatibility mode.
File access is going to be limited based on the identify of the application pool that is hosting your service. Your service will be able to access any file the application pool identity has access to whether it is in the root of your IIS website or not. If you want to access files within the root of your website using relative paths with something like Server.MapPath then you'll have to run your WCF service in ASP.Net compatability mode. See the following page for details on WCF with ASP.Net compatability mode:
http://msdn.microsoft.com/en-us/library/aa702682.aspx
I think that the best approach is to create another application pool for your service and assign a specially created account as the identity of your new application pool. Then give the needed permissions of the account to the folders and file you need to access. You can make the external folder a virtual directory of the site if you want to reference it with a relative path.

How to configure the wcf service to view the test page without pointing to svc file in address box?

I have created a working wcf service. I have come a cross a page regarding wcf services
which describes the process for eliminating default wcf service page.
It is here https://github.com/geersch/WcfServiceMessage
Except for the things the author of this page is describing, I have one question.
How has he managed to configure the IIS or Web.config to host page with the address: http://localhost:8732/HelloWorld/ ?
At home, the only address I see my service at is: http://localhost:8732/MyServiceName.svc
(with svc extension)
How has he done it that the endpoint address: "HellowWorld" is used?
Thanks!
The WCF service endpoint is not actually a file. The total url itself is what the server recognizes as something to service, so the HelloWorld piece is just as good as HelloWorld.svc.
This is a difference between IIS hosted service and Windows or Visual Studio service host (cassini). In iis, you do have to specify a file that ends with svc and make that extension known. In iis you can also set a svc file as the default file to open if a specific directory is opened. that way you can achieve the same behavior.

Optimizing wcf service in IIS

I am hosting a ASP.NET web site containing a wcf web service in IIS 7. The web service is exposed using a .svc file that resides inside the web site's virtual directory.
There's section is this document about optimizing the web service performance by removing unnecessary http modules:
http://msdn.microsoft.com/en-us/library/ee377061(v=bts.10).aspx
My question is how can I do that in the web config without affecting the web site? My ASP.NET web site contains authentication stuff and definitely requires some of those modules (eg, FormsAuthentication). Is there a way to enable those modules only for the web site but disable them when the clients access the web service?
Thanks
You should separete your project into two (web and Service).
After that, create a website into IIS and add those two application separatedly, like that:
That way you can handle different configurations for each site, and configure the modules for a especific "project" (like wcf service).

Using a WCF Service Library from Silverlight

I've added a WCF Service Library to a Silverlight project. But when I try calling a method on the service I get a CommunicationException complaining about accessing a service in a cross-domain way.
I've tried adding both a crossdomain.xml and clientaccesspolicy.xml to the service library project, but it doesn't help.
Any idea what I'm doing wrong?
You mention that the policy files are going into the service library, have you checked they get placed into the correct place within the website?
Try running up fiddler to see what the web site is actually returning when the service is called.
Copy CrossDomain.xml and clientpolicy.xml files in C:\Inetpub\wwwroot path. :)