Access WCF service from Silverlight - wcf

I am trying to access a WCF service from silverlight application .I have hosted this service in local IIS and checked if that I am getting service correctly but when I try to access it from silverlight I am getting crossdomain error .
I checked few threads on MSDN and stackoverflow placed clientaccesspolicy.xml and crossdomain file in root folder of my IIS but I still get this same error .
can anyone help me out .

If you install a tool like fiddler (or any other software that lets you see what requests are made) you can track on which path the policy file needs to be. In most cases you used the wrong directory for the file or there is no request made because it's cached somewhere.
Check if your file is where it is supposed to be. Most likely, it's not.

Related

How to deactivate a service under an IIS host

I have more WCF services under an IIS virtual directory. I have to deactivate some of them and I thought, I have just commet out the appropriate sections in the web.config, but it seems not, the client works. Just in the browser comes the error message, that the metadata is not reachable.
Is it actually possible to somehow deactivate the services?
I had an another idea, to rename the .svc files, but I want to avoid that solution.
I am using .Net 4.0.
I've found that:
Simplified Configuration for WCF Services:
http://msdn.microsoft.com/en-us/library/ee530014%28v=vs.100%29.aspx
If you have only one service in the Web application, you may simply stop the app pool associated with the service, provided you have one app pool per web application.
If you have more than one services in the application and you just want to deactivate one,you may remove the respective svc file; or if you use config activation without any svc file, you may comment out respective line in the config. For more details about how to activate services without SVC files, you may read http://www.codeproject.com/Articles/627240/WCF-for-the-Real-World-Not-Hello-World and check the source codes attached in the article.

Do I have to build the WCF Client for each machine its used on?

I've built and compiled my WCF client to run successfully. I've found that as long as these two files are together, my client will run anywhere on my computer:
Client.exe
Client.exe.config
When I move these files to another computer, there's an error:
System.InvalidOperationException: Could not find default endpoint element that
references contract 'Service.IService' in the ServiceModel client configuration
section. This might be because no configuration file was found for your
application, or because no endpoint element matching this contract could be
found in the client element.
I've already made sure that the service URL is accessible from the intended host of the computer.
After looking up the issue, seems like a solution is to copy the config retrieved from executing:
svcutil http://host/Service.svc
to the application configuration file. However, the config info is already in the App.config file when I built the project.
Do I need to recompile/build on every client machine that intends to use the WCF web service?
I seem to have resolved this by copying over the entire compiled folder:
Client.exe
Client.config.exe
Client.pdb
Client.vshost.exe
Client.vshost.exe.config
I don't have the time to go back and forth to see which subset of files are core or whether all these files are necessary, but hopefully someone can follow up with an answer to that.

IIS - Resource not found while Directory is browsable

I have a little strange issue on my system. I have hosted a Service, Rest Service (Be Specific) on my system. When I try to access the svc page of the same service it gives me HTTP 404 (The resource cannot be found.) error while I can browse the whole directory and in that directory it shows that the svc file lies with in the folder but when I click on svc file i get the 404 error.
I tried to host the same service on other system and it works fine. I am not sure what causing it not to display on my system.
Any clue would be great help.

WCF Service Deployment in IIS Page cannot be displayed and how does the SVC file work?

Arghhh! I'm getting so frustrated trying to get my head around this WCF service.
So I created a WCF service. It works fine in my laptop where I launch it from Visual Studio 2010. Now I have to deploy it on a Windows Server 2003 machine. So I created a virtual directory on that server's IIS. Next I copied the WCF Service DLL file in the virtual directory. I also created an SVC file which had the following entry:
<%# ServiceHost Language="C#" Service="AMWCF.Service1" %>
Ok first of all, I'm so confused here. Where does this line tell the Server where the DLL file is? It just says "AMWCF.Service"! not file location!
So when I try to launch my webpage, it gives an error "THE PAGE CANNOT BE DISPLAYED". I've tried everything which I can find on the net including:
Reinstalling the ServiceModelReg
Restrarting IIS
Allowing ASP.NET in IIS
Sorry for showing my frustration here. I really really reallllly appreciate any help. Thanks guys. You guys are the best
If you have a class library with your WCF service inside, you need to copy the service DLL into the .\bin folder one level down from your virtual directory. That's where the WCF runtime looks for its service classes.
Also see these resources:
MSDN docs: How to: Host a WCF Service in IIS
endpoint.tv Screencast - Hosting WCF Services in IIS
The WCF Developer Center on MSDN has a "Beginnger's Guide" (available right from the landing page) which has tons of those excellent 5-10 minute screencasts explaining all things WCF to you - highly recommended!
Page cannot be displayed error is coming from IIS.
Add a simple html file and see if IIS can serve that file
Add a simple aspx file and see if IIS can serve that file
Now add .svc file as one of the documents in document list in IIS
Place dll in a bin folder under the virtual directory's physical path
Once you get the asp.net run time errors, it is easy find the answers
for them
If this stuff is new to you, you should use the visual studio deployment features, try right click your web project and click deploy, I think it'll solve your issues, you can even deploy using ftp through this wizard.

Cannot put .svc file to IIS hosted WebDAV directory - logs say HTTP error 405

I am trying to publish via something more reliable than the FTP option, which works very intermittently from visual studio - and is very slow. So let me first ask you: In 2011, using visual studio to publish, is WebDAV the best option?
Anyway, I've got WebDAV hosted by IIS 7 up and running, and I have managed to map it as a drive. I can copy files there aswell, except anything with the file extension .svc. I can publish everything else I've tried, and also publish the .svc file if I first rename it to something else, then renaming back after it already is in the WebDAV directory.
Here is the IIS log:
2011-03-19 18:32:54 192.168.0.9 PROPFIND /bin/service.svc - 80 SERVER\User my.ip.not.shown Microsoft-WebDAV-MiniRedir/6.1.7600 405 0 0 0
As you can see, it ends in 405.
The only similar thing I've managed to google up could be solved by configuring the , and sections of the applicationHost file. The logical thing would be to check for an entry in , but it says nothing about .svc. I've also tried setting applyToWebDAV to false.
Any ideas?
UPDATE:
Thinking on it, could it simply be that the WCF http handler intercepts the url, since .svc is registered with that handler?
Alright, I figured it out. The WCF handler was ordered before the WebDAV handler in the handler mappings, so it intercepted requests to *.svc. It in turn returned 405 method not allowed for PROPFIND.
Simply move the WebDAV entry upwards in the list until it is listed appropriately early in the mappings.