none
WCF Error: 404 Not Found. Please help. RRS feed

  • Question

  • I created a simple WCF REST servicem hosted in IIS 7.5. There are two methods in the service.  One is "getuser", the other is "login". The "getuser" one works but the "login" one returns code 404. I have tried all options by searching web site but I cannot figure out why.  Service definition is attached below.

    Thanks,

    Chris

    [OperationContract]
            [WebInvoke(Method = "POST",
                RequestFormat = WebMessageFormat.Json,
                ResponseFormat = WebMessageFormat.Json,
                UriTemplate = "login")]
            LoginResponse login(LoginRequest request);


            [OperationContract]
            [WebInvoke(Method = "GET",
                RequestFormat = WebMessageFormat.Json,
                ResponseFormat = WebMessageFormat.Json,
                UriTemplate = "getuser/{username}")]
            LoginResponse getuser(string username);

         
    Monday, March 11, 2013 9:13 PM

Answers

All replies

  • Hi,

    How do you implement the login method and call the mothod at client side? You can refer an example in below blog for how to create a POST function.

    #REST  Eanbaled Service in WCF Tutorial

    http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/rest-eanbaled-service-in-wcf-tutorial/

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 12, 2013 10:14 AM
    Moderator
  • Thanks for the replay. I removed all my code, only a log statement in the body. Somthing like this.

       public LoginResponse login(LoginRequest request)
       {

                Log.logDebug("Login: " + request.ToString());

              return new LoginResponse();

    }

    This method is not called at all.

    Interestingly, this happens only on the deploy machine. On my development machine both methods work.

    I use RestClient in Firefox to test. The same client is used on my dev machine and deploy machine.

    I thought the deployment was the issue. I tried to xcopy the whole folder to deploy machine, but I still get the same error.

    Is there any debug logging I can turn on to diagnose the issue?

    Wednesday, March 13, 2013 9:15 PM
  • Hi,

    You can turn on tracing for your service and use SvcTraceViewer.exe tool to analyze the diagnostic traces.

    #How to enable WCF tracing

    http://blogs.msdn.com/b/madhuponduru/archive/2006/05/18/601458.aspx

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 14, 2013 3:07 AM
    Moderator
  • Thanks!

    I installed Windows SDK on the deployment server and followed the instructions to trace service.

    The working methog is recorded in the trace log, but there is nothing for the second method.

    That seems the request does not reach to the service part all all.

    How can I diagnose where the request is stopped?

    Friday, March 15, 2013 1:15 AM
  • Hi,

    Since the brower requests the service using HTTP GET, but the "login" method is mapped to POST, when you call it from the browser, it will result in "Method not allowed" error. You can change the "login" method to "GET" or try calling the method from Fiddler or WcfTestClient.

    And please refer a sample in the blog I posted above to create a "POST" method.

    If the issue still exists, please elaborate below points more clearly.

    >>this happens only on the deploy machine

    Do you mean the "login" method does not work by calling the service from an application that located in your "development machine" after deploying the service to the "deploy machine"? And do you mean it works as expected when the client and service are located in the same "development machine"?

    >>I thought the deployment was the issue

    How do you deploy the service and how do you call the service from a client.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 18, 2013 6:41 AM
    Moderator