I just set up a simple WCF service on my dev environment, and so far the endpoints are working OK, for both SOAP and JSONP requests.
I've proceeded to deploy this solution to a staging server hosted on IIS 5.1 (old, I know, but bear with me), and the .svc files suddenly aren't working anymore. Not that IIS can't find them, but rather they're getting served as plain text files.
This is basically what shows up on my browser when I pop in an .svc file:
<%# ServiceHost Language="C#" Debug="true" Service="service.myservice" CodeBehind="myservice.svc.cs" %>
Now I've tried all the solutions I've seen around SO and other sites (including reinstalling the ASP.NET binds on IIS using aspnet_regiis and reinstating the WCF ISAPI handles using servicemodelreg.exe), but none of them work.
One quirk that may be of note is that the IIS 5.1 is serving off port 8000, because Apache is currently running on the default 80. Could this be a culprit? I've tried running servicemodelreg -s:myservice to try to hit my app path squarely, but it tells me that there's no such application on IIS:/localhost/myservice (maybe because it's supposed to be on IIS:/localhost:8000/myservice? I'm not sure.)
I've verified that I've got a functional .NET 3.5 framework down, the .aspx files are served OK. It's just the .svc files that aren't getting served properly.
Any ideas?
If servicemodelreg hasn't worked, check that the .svc is set up with an ISAPI mapping.
Go to the Home Directory tab on the properties of your web site, select Configuration...
If .svc isn't present in the list, set it up with the following parameters:
Executable: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
Extension: .svc
Limit to: GET,HEAD,POST,DEBUG
Script engine: Ticked
Related
I have developed and published (via the "publish" feature in VS 2013) a simple WCF web service on IIS on my local machine.
The physical deploy path is the folder : c:\inetpub\wwwroot\MyWCF_Service_On_IIS\
I saw on IIS that the virtual folder has been created under "default Web site" (with the same name : MyWCF_Service_On_IIS). The default web site listens on port 80.
Why there is no way to access the service ? whatever combination of paths and urls fails.
I tried :
localhost/MyWCF_Service_On_IIS/Service1.svc (Service1.svc is the .svc file hosting the only endpoint);
localhost/Service1.svc
127.0.0.1/MyWCF_Service_On_IIS/Service1.svc
127.0.0.1/Service1.svc
localhost
127.0.0.1
Even if I don't expose metadata endpoints I expect to see a least a help page about the service and how to get the metadata themselves.
But I only get errors
Whatever attempt I do fails miserably.
I would like to know, once and for all, what is the rule IIS uses to map virtual folders to physical folders.
We are supposed to directly deploy all related files/file directories to the root folder of the website by using FileSystem mode.
C:\inetpub\wwwroot
Moreover, we need to enable windows features to handle the SVC extension for supporting WCF service.
There is no need to use a virtual folder in that case.
Here is the content of the wwwroot folder on my side.
bin folder
PrecompiledApp.config
Service.svc
Web.config
The service URL is http://localhost/service.svc
If we specify the URL by using a virtual path. We should convert the virtual path to the application.
Then the service URL is http://localhost/MyWCF/Service1.svc.
Feel free to let me know if the problem still exists.
I have developped a wcf web service in VS2010. The web service works good in VS2010, added the web service reference to a project (winform) in the same solution, everything works great, call of methods, good.
When I deploy my web service I get :
The webpage at (website) might be temporarily down or it may have moved permanently to a new web address.
I'm new to WCF web services, what do I need to deploy to make it work correctly?
I deployed the .svc file and web.config.
I deployed all .dll files in the bin directory.
I check my project folder, there is aa Web.config, Web.Release.config and Web.Debug.config.
Do I need to deploy Web.Release.config? But there is not much of a content in it :
<?xml version="1.0"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
In my Web.config I have the appsettings, bindings, services and all, do I need to copy all the stuff in my Web.Release.config file?
Any solution/suggestion?
Thanks.
To host your WCF project (or anything in IIS, for that matter), it would be worth a read over Hosting in Internet Information Services. You can deploy your project by following the directions at WCF Service Publishing.
For an example solution, lets assume you are using a machine with IIS 7. Open Internet Information Services (IIS) Manager under Administrator Tools.
First we will choose or create an Application Pool for our application to use. It can use an existing Application Pool as long as it uses the same .NET version, or you can create a new one. You will likely have something similar to:
Next, you will choose a Site to host your WCF service. You can use an existing site or create a new site. I am going to just use Default Web Site, and will Add Application...
This physical path will be where you deploy your WCF project. Say that your host machine is named MyHostMachine. To deploy your WCF, right-click your project, select Publish...
In that popup, select Publish method of Web Deploy, set the Service URL (ex: http://MyHostMachine), and Site/application (ex: Default Web Site/MyWcfService).
Note: If you have any permission issues that prevent you from doing a Web Deploy, then you can simply deploy to somewhere in the local File System, and copy the full contents from there to the application directory on your host machine.
In MyCase it's just changing applicationURL value from https://localhost:portNumber to http://localhost:portNumber in Application > profiles > webapplication > launchSettings.json .It got worked.
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.
I created a WCF REST (aka WebHttp) service in .NET 4, using Microsoft's WCF REST Service Template 40. I am hosting the service in IIS 6.
The Service Template uses the RouteTable in the Global.asax as a way to create "clean" URL's that don't include ".svc" in them. For example:
http:// localhost / flights / 878
GET and POST work fine against this URL, but PUT and DELETE result in HTTP 501, "Not implemented".
If I create a simple .svc file like this:
<%# ServiceHost Language="C#" Debug="true" Service="MyProject.FlightsService"%>
then I can use PUT and DELETE against this URL:
http:// localhost / flightsservice.svc / 878
Does anyone know if it's possible to get PUT and DELETE to work against the "clean" URL above? It seems that there is no way to configure IIS to allow this because there is no file extension to configure settings for, and I don't want to allow PUT and DELETE globally.
I haven't worked with IIS6 in a while (and I don't have it installed, so I'm going off memory here), but I had to implement something similar with IIS6 for routing extensionless URLs in IIS6.
You can enable wildcard script mappings on a folder by folder basis by hacking IIS Manager. This blog post is what I followed and it works really well (and this link provides a little more background). It's really a bug in the Manager, not IIS itself (at least that's what I tell myself).
Can you reference your services in a sub-folder in your site (e.g. http://localhost/services/flight/878)? If so, and if you implement the IIS Manager hack above, I think you can enable all HTTP verbs for that directory. Again, I'm going off memory (and we only implemented GETs and POSTs, so I didn't deal with PUTs and DELETEs), so I hope I'm getting this right.
Let me know if you need more info or if my memory is slipping. :) I hope this helps!
If your web application is getting deployed to multiple dev/production environments, then the best way seems to be disable WebDAV at the web.config level. To do this, remove the WebDAVModule and the WebDAV handler as in the below example:
<system.webserver>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webserver>
I have been working on a Silverlight app that consumes a WCF service. [on Visual Studio]
as a matter of simplicity I created a WCF service in the project itself [as-in I didnt host it in IIS, but let the build-in webdev server in VS do it for me]
It works well, now I want to deploy it on IIS 7.0, can you tell me If i would need to host the service independently and then the remaining stuff or if I just publish the website, the service would be hosted too and the Silverlight client would be able to communicate with the service.
Please help!
Thanks
You basically need
a virtual directory in IIS 7
a SVC file (service file) that instructs IIS how to instantiate your service
You basically have three options to deploy your service implementation:
you can put your service implementation into the code-behind file of the SVC file - that would be my least favourable option - basically don't do it - it gets messy and offers no benefit
you can put your service class file (the MyService.cs file) and the interface file (IMyService.cs) into the App_Code directory (if you're using a Web Site project type) - again, I don't particularly like this approach
your best option: put your service contract (the interface) and your service implementation into a separate class-library assembly for that service, and deploy that MyService.dll into the .\bin directory below the virtual directory where your SVC file lives.
Then add a *.svc file (pure text file) to your virtual directory, which contains:
<%#ServiceHost language="c#" Debug="true" Service="MyService" %>
And of course, you need the appropriate web.config entries - but I'm sure you already have those, right?
Your service address now is:
http://YourServer/VirtualDirectory/YourService.svc
For more info, see How to: Host a WCF Service in IIS
Marc got you the how. In response to your question around need, you will both need and want to separate the services from the Silverlight assets (static references and XAPs). This might not make a lot of sense for smaller sites but as you grow in size this affords you the opportunity to locate your Silverlight assets on a location separate from your services (such as a content distribution network) so that they can be delivered to users as fast as possible.