13

I moved from IIS 6 on windows server 2003.

I can browse to the .svc files. I get a nice standard "This is a Windows© Communication Foundation service" page if I go to http://example.com/Service.svc in a browser.

But I can't browse to any of the methods - I get a 404 error if I go to http://example.com/Service.svc/Method?parameter=xyz in a browser.

Has anyone seen anything like this? Any ideas or suggestions?

I thought I might have a similar problem to this question: WCF on IIS8; *.svc handler mapping doesn't work

But the symptoms are different (looks like they can't see .svc files at all) and none of the solutions work (I have Http Activation for WCF features installed, etc).

Community
  • 1
  • 1
MGOwen
  • 5,951
  • 12
  • 51
  • 64
  • Is Method is `HTTP` `Get` or `Post`? – Pranav Singh Oct 16 '14 at 07:00
  • Pretty sure all the methods are GET, but there are several different endpoints by different developers (none are working). – MGOwen Oct 16 '14 at 07:05
  • Is this a RESTful WCF service or a normal SOAP WCF service? If it's SOAP, try `http://example.com/Service.svc`. You'll need a proxy to call the methods. – Tim Oct 16 '14 at 07:10
  • Are there any authentication set in WCF, or specific header has to be set before making `GET` request? Or are you trying to execute `GET` request from browser directly? What do you mean by `browse to any of methods` - is it , just to get list of all methods and signatures? check this link - http://stackoverflow.com/questions/18989423/run-wcf-methods-from-a-browser – Arindam Nayak Oct 21 '14 at 12:04

5 Answers5

29

OK, I gave up and paid Microsoft $250 for support. With the tech's help, we found the solution, and last night confirmed that it was definitely the solution for all our servers: We disabled SSL altogether for WCF services in the web.config:

<system.serviceModel>
    <bindings>
        <webHttpBinding>
            <binding>
                <security mode="Transport" />

The "Transport" refers to Transport Layer Security (TLS is the new SSL) so HTTPS. Changed that to:

<system.serviceModel>
    <bindings>
        <webHttpBinding>
            <binding>
                <security mode="None" />

Turns out WCF is extremely sensitive to whether you are using HTTP or HTTPS, and if you are using the wrong one you get no helpful errors, just 404.

In my case, both old and new servers were configured to use HTTPS at all times for security. But on the new servers, the SSL (TLS) encryption terminated on the load balancer. In that case encryption only happened between the user's browser and our load balancer, and the traffic between our load balancer and the web servers was unencrypted HTTP.

So the service was listening on HTTPS, and when the request came on HTTP, it just completely ignored it.

(All the other talk about similar issues online focused on uninstalling and reinstalling IIS and ASP.NET and WCF and HTTP Activation and such, so I hope this helps someone. I recommend MS Support if you have a question on the MS stack that SO can't answer in time. It was certainly much cheaper than wasting a few more hours trying to fix it alone).

MGOwen
  • 5,951
  • 12
  • 51
  • 64
  • in the end it turns out to be the issue, that i was telling you in comment to my answer. Just an FYI, in case you missed my comment to my answer post. – Arindam Nayak Oct 24 '14 at 06:04
  • 1
    Yes (although we'd already solved it by the time you made that comment). Thanks for taking the time to investigate and reproduce the error. Outstanding work, enjoy the bounty! – MGOwen Oct 24 '14 at 22:25
  • 1
    Changing my "Transport" to "TransportCredentialOnly" allowed me to test my service using HTTP. – yourbuddypal Sep 28 '15 at 22:07
  • We have a wcf service behind an F5 which transfered https to http behind the scenes.. this fixed it – VisualBean Apr 07 '16 at 09:02
14

Please check if your IIS has svc handler added.

WCF services don’t run on IIS 8 with the default configuration, because the webserver doesn’t know, how to handle incoming requests targeting .svc files. You can teach it in two steps:

  1. Add a new MIME type:

Extension: .svc MIME type: application/octet-stream

enter image description here

  1. Add a new Managed HTTP Handler:

    Request path: *.svc Type: System.ServiceModel.Activation.HttpHandler Name: svc-Integrated

enter image description here

Refresh your website/web application

References:

http://gyorgybalassy.wordpress.com/2012/09/24/publishing-a-wcf-service-on-iis8/

http://proq.blogspot.hk/2012/09/wcf-on-iis-and-windows-8.html

http://forums.iis.net/t/1200413.aspx?+svc+missing+can+t+find+Module+to+load+within+Handler+Mapping+IIS+8+0

Pranav Singh
  • 13,233
  • 23
  • 66
  • 87
  • Thanks! But I did already try this unfortunately. I found that first link, and followed the instructions - no change. (I did notice that *System.ServiceModel.Activation.HttpHandler* was not in the dropdown - there were other namespaces in there, but not that, I had to type it in. Any idea if that tells us anything?) – MGOwen Oct 16 '14 at 07:33
  • Its not supposed to be in dropdown. Did you try adding manually? – Pranav Singh Oct 16 '14 at 07:41
  • Please also check if .Net 4.0 or 4.5 whichever you are using & wcf are installed on server. may be it isn't installed so assemblies are not in GAC. – Pranav Singh Oct 16 '14 at 07:43
  • Yes, I added it manually (typed it into the box like in the screenshot). .Net 4 and WCF are definitely installed on the server, checked that numerous times. – MGOwen Oct 16 '14 at 07:51
  • Please check if this works for you http://stackoverflow.com/questions/11116134/wcf-on-iis8-svc-handler-mapping-doesnt-work – Pranav Singh Oct 16 '14 at 08:29
  • Yes, that's the link I included in the original question, saying I'd tried all of those. As far as I can tell, that issue is where you **can't** browse to .svc files. I don't have that problem, I just can't see/use the methods of those .svc files. – MGOwen Oct 16 '14 at 08:47
  • I had to install also the feature `.NET Framework | WCF Services | HTTP Activition` – AxelWass Apr 07 '17 at 16:07
3

Just wanted to provide a collection of suggestions in case you haven't tried one of these:

  • Any chance the [OperationContract] is missing for the intended method?
  • Do you have any url rewrites configured in the web.config that could be redirecting the method calls, such as an HTTP/S redirect or some route configuration?
  • Enable Failed Request Tracking in your IIS to see what sub-type of 404 error you are getting? 404.13? something else? It is likely not because something isn't found, but some other error in the request.

Additional Sources:

Community
  • 1
  • 1
Jason W
  • 12,449
  • 2
  • 24
  • 57
2

You can enable tracing/logging in wcf service , so that you can check actual cause of error, if there is mismatch in param or any other thing , directly from error logs.

Refer this to enable tracing, it is just simple config setup - http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx or How to turn on WCF tracing?

...

Other suggestions:

In ServiceContract, for required method, you have used required attributes. So lets say, Service.svc has servicecontractor defined in IService.cs, and you are concerned about Method. Then Method should be declared like this.

[OperationContract]
[WebGet(UriTemplate = "Method?parameter={value}")]
string AnyMethodName(string value);

Here i have used string as both input and output param type, you can use required type here. Apart from this, you need to have required web.config to have service,binding,endpoint etc. configured properly. Refer - http://msdn.microsoft.com/en-us/library/ms733932(v=vs.110).aspx

So that if you host it in http://www.example.com, then you can execute REST based Get request using http://www.example.com/Service.svc/Method?parameter=XYZ.

More info - http://www.c-sharpcorner.com/UploadFile/b1df45/rest-based-api-using-wcf-services/

Also, as suggested above, there might be some URL rewriting setup, that you have check and fix. or try with https version of URL directly. Or if there is some proxy server that is blocking, has to be checked.

If there is request filtering setup, then check if GET request is blocked there.

Or if at all possible, re-register IIS using aspnet_regiis.exe -iru.

Community
  • 1
  • 1
Arindam Nayak
  • 7,138
  • 4
  • 28
  • 45
  • Yes, as I said, the service works find in the old production server, so ServiceContract, endpoints, bindings, etc are fine. Tracing is a good idea, trying that... – MGOwen Oct 22 '14 at 22:44
  • 2
    @MGOwen , got your issue reproduced, i have deployed sample WCF app to 2012 server with IIS 8.5, when i browsed `HTTPS` version of site `.svc` worked, but when i used `.svc/Method?parameter=xyz` it did not worked (`404 error` - same as yours), and later tried same URL with `http` worked, and found that, i haven't configured WCF app with `https`, that is why for `https` version, it shown me `404` error, might be this is the root cause of problem. Conclusion, even if you don't set `https` for wcf, browsing `.svc` will work, but not `GET` request. – Arindam Nayak Oct 23 '14 at 06:28
  • @MGOwen, also vice-versa, is true, i.e. if `HTTPS` is configured in `web.config` of wcf service, `HTTP` link will not work, it'll say `404` error. Check if the new server is constantly redirecting to `https` site and you don't have `https` enabled in wcf, then probably that is the reason. Use `Fiddler` or `chrome network console` to check. http://msdn.microsoft.com/en-us/library/hh556232(v=vs.110).aspx - set `https` in web.config. – Arindam Nayak Oct 23 '14 at 07:28
1

Hope it will help to somebody though its late to reply to this post. I got the same problem and spent hours and hours to find the solution. Finally ended up changing

Luckily I got the answer changing RouteConfig.Cs file as follows From

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

To

routes.IgnoreRoute("{resource}.svc/{*pathInfo}");

as long as you should place your .svc file in root of your application.

That was my own question asked on this link WCF Service throws Http404 on any request except .svc

Community
  • 1
  • 1
Ishwor Khanal
  • 1,039
  • 14
  • 26
  • Of course! I was doing some WCF tests in a new Web Application project that had all web technologies included (Web API, Web Forms, and... MVC!) Thanks for the heads-up +1 – Mzn Jan 22 '17 at 03:47