(405) Method Not Allowed. WCF WebService

Grossu Iulian picture Grossu Iulian · Mar 1, 2016 · Viewed 15.1k times · Source

Introduction:

Hello, I am trying to set up a WCF web service on my local IIS 7.5 server, however after I finish the basic configurations I am unable to send data with a WinForms test client and it returns the error mentioned in the titles. I have already searched similar threads on this problem but i did not find anything that would fit my problem.

Data:

-Both the Wcf WebService and the test client where provided from a 3rd party

-They already work on another server and I am using the same versions

-I am probably doing something wrong when I enable or configure IIS

Request:

-I need to know what IIS features I need to enable/disable in order to install it correctly so I can use the Wcf WebService.(If that's the case).

-How to correctly configure the server in order to solve the above mentioned error.

My Configurations:

-After Installing IIS I changed the DefaulAppPool to .NET Framework v4.0.30.319; pipeline mode: Integrated. -Advanced Settings: Load User profile = False.

-Created a new Website named "WcfMicrocontrollerService" using DefaultAppPool.Binding; Type:http, IP adress: , port: 80

At this point I can access it trough a web browser, however when I use the test client to POST data to the service I get the following error: "The remote server returned an unexpected response:(405) Method Not Allowed."

Here are the data packets sent as recorded by Fiddler: Sent:

POST http://192.168.0.102/MicroControllerComSvc.svc HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IMicroControllerComSvc/GetMicrocontrollerData"
Host: 192.168.0.102
Content-Length: 237
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><GetMicrocontrollerData xmlns="http://tempuri.org/"><microControllerData>1,1,1,1,2,2,1,0,100,300</microControllerData></GetMicrocontrollerData></s:Body></s:Envelope>

Received:

HTTP/1.1 405 Method Not Allowed
Cache-Control: private
Allow: GET, HEAD, OPTIONS, TRACE
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 01 Mar 2016 10:44:44 GMT
Content-Length: 5671

And here's the body: https://dl.dropboxusercontent.com/u/2237590/405.html

This seems to indicate that I should take a look in handler mappings but I have no idea what to edit there.

Answer

simlawstu picture simlawstu · Mar 1, 2016

Ok so after a very brief search about your issue I found the following question WCF on IIS8; *.svc handler mapping doesn't work

Ignoring the fact that the question is about IIS 8, are you running Windows or Windows Server?

If you are using Windows go to...

  • Control Panel -> Programs -> Programs and Features > Turn Windows Features on or off. Under the ".Net Framework 3.5 (Invlucdes .NET 2.0 and 3.0" section
  • make sure that "Windows Communication Foundation HTTP Activation" is turned on.
  • Also check under ".NET Framerwork 4.x Advanced Services" and under "WCF Services" check to ensure that HTTP Activation is turned on there as well.

This is a picture from that question showing the .net 4.5 change to make. Features to turn on

If you are using Windows Server try following the first answer to the question regarding how to set up the role using server manager.