Web Service error - Request format is unrecognized.

Problem Statement:

While trying to browse an asmx Web Service, you get the following error:

 Request format is unrecognized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Request format is unrecognized.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
 [InvalidOperationException: Request format is unrecognized.]
 System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +169401
 System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +209
 System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
 System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +308
 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

 

Resolution:

In the Web.Config file of the service, make sure you have “Documentation” enabled for <webServices>

     <webServices>
            <protocols>
                   <add name="Documentation"/>
            </protocols>
    </webServices>

If the “Documentation” attribute is not present, please add it to the protocols as above.

 

What is <add name="Documentation"/>?

Answer: Adds the special Documentation protocol. When this protocol is enabled and the .asmx page is requested directly, ASP.NET runs a helper page to create a documentation HTML page that is delivered to the requesting client.

The documentation protocol generates an XML-formatted Web Services Description Language (WSDL) file. This file is designed to allow applications to understand how to structure requests to the Web service.

Please refer - https://msdn.microsoft.com/en-us/library/4yx7be39(v=vs.85).aspx

This information can be very useful to developers, especially developers who create clients for public Web services.

However, revealing detailed information about the functionality of private Web services increases the risk that the Web service will be misused by a malicious attacker. The Documentation protocol always describes all functions and parameters of a Web service — even if only a subset of those functions are intended to be publicly accessible.

To remove the Documentation protocol please refer - https://support.microsoft.com/en-in/kb/815149

 

Hope this helps!

Created by Saurav Dey(MSFT)

Comments

  • Anonymous
    November 30, 2016
    Thank you very much This solved my issue
  • Anonymous
    November 30, 2016
    Thank you very much. This solved my issue.