none
IIS redirecting to WCF service results in a 405 error. Why?

    Question

  • Here is the setup:

    I am deploying my WCF service as a windows service running on a machine we will call MYMACHINE. It listens on port 8768 and is self hosted within this windows service.

    This WCF service is actually using a REST, waiting for folks to POST some XML to the service. I can do this (using Fiddler) by POSTing some XML with a URL of http://MYMACHINE:8768/MyServiceProcess. Groovy. It works quite nicely.

    Now things start to go south.

    MYMACHINE has an SSL certificate, ready to go and installed in IIS. My client wants to make certain the XML data they send will be over a secure connection, which makes perfect sense. Cool, I think, I'll just have IIS handle the SSL cert, take the POST requests it receives, and redirect / forward everything to http://MYMACHINE:8768/MyServiceProcess.

    Now, though, when I try to post some XML to https://MYMACHINE/MyServiceProcess (note the 's' there -- we are now using SSL, and also note the lack of a port), I observe that IIS returns a 302 (redirect) code, and then my WCF service returns a 405 (method not allowed). In trying to resolve this, I note that even if I avoid the whole SSL thing, i.e. I post to http://MYMACHINE/MyServiceProcess -- again no port, though, because I'm expecting IIS to redirect), I still get the same 405 error.

    Any hints and suggestions as to how to resolve this? What am I missing?
    Wednesday, June 09, 2010 9:54 PM

Answers

  • This is because "302 (redirect)" forces client to request another resource using GET, not POST. So your WCF is invoked using "GET" - thats why you got "405 (method not allowed)".
    Monday, June 14, 2010 7:34 AM

All replies

  • Hi,

    From your description you have a WCF REST service that works in development server but doesn't work after publishing to IIS, right? Could you share a demo project for me to reproduce this issue? You can upload the project to http://skydrive.com and paste download link here.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Windows Azure Platform China Blog: http://blogs.msdn.com/azchina/default.aspx
    Monday, June 14, 2010 3:13 AM
    Moderator
  • This is because "302 (redirect)" forces client to request another resource using GET, not POST. So your WCF is invoked using "GET" - thats why you got "405 (method not allowed)".
    Monday, June 14, 2010 7:34 AM
  • Hello,

    why don't you expose HTTPs endpoint directly on your service?

    Best regards,
    Ladislav

    Monday, June 14, 2010 8:41 AM