locked
Add Servive Reference Error RRS feed

  • Question

  • User-1771888428 posted

    I get this error when I want to add a copy of a service to web forms 4.5 project project. the web service still working for web forms 4 project but does not add to my new project:

    error:

    The HTML document does not contain Web service discovery information.
    Metadata contains a reference that cannot be resolved: 'http://localhost:60194/AdminServices/AccountAdmin.asmx'.
    The content type text/html; charset=utf-8 of the response message does not match the content type of the binding 
    (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported
    method is implemented properly. The first 1024 bytes of the response were: '

    All of the web service methods have signatures like this:

    [WebMethod]
            [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
            public object DeleteUser(string data)
            {
                string[] items = data.Split(',');
    
                string userName = items[1]; // the last item separated by comma ','
                if (userName == null || !(userName.Length >= 1) || !(userName.Length <= 50))
                    throw new ApplicationException("Data Error");
    
                try
                {
                    Membership.DeleteUser(userName, true);
                }
                catch (Exception ex)
                { }
    
    
                
                return SearchUsersByPortionEU(items[0]);
                
    
            }
    

    How do I add this service. (using VS2017 and .net 4.7 and Asp.Net 4.5)

    EDIT:

    I created a new default web service file (asmx) it is not also added with the same error, is there any configurations for asmx that I missing?

    Sunday, January 13, 2019 7:06 AM

Answers

  • User-1771888428 posted

    Web service references are not still added. But in my case I didn't want that, the only thing that is required is a servicereference in scriptmanager like this:

    <asp:ScriptManagerProxy ID="myProxy" runat="server">
            <Services>           
                <asp:ServiceReference Path="~/AdminServices/AccountAdmin.asmx" />
            </Services> 
            
        </asp:ScriptManagerProxy>

    and then calling methods like:

    MyWebForms.AdminServices.AccountAdmin.SearchUsersByPortionEU(passString, OnRequestCompleteSort, OnErrorSort);

    I copied this page from my previous project and I forgot to add script file "jquery.validate.js" and because of the logic of button clicks that were called after validation, the page got a full refresh and e.preventdefault was not called, so not working. after adding "jquery.validate.js" page worked.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 13, 2019 10:53 AM

All replies

  • User1120430333 posted

    The HTML document does not contain Web service discovery information.
    Metadata contains a reference that cannot be resolved: 'http://localhost:60194/AdminServices/AccountAdmin.asmx'.
    The content type text/html; charset=utf-8 of the response message does not match the content type of the binding
    (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported
    method is implemented properly. The first 1024 bytes of the response were:

    I mean the information is clear as to what is wrong. It looks to me that the service reference is blowing up as VS is trying to create the reference. VS should be telling you more in detail  about the issues with the reference with some kind of reference error page.

    Sunday, January 13, 2019 8:02 AM
  • User-1771888428 posted

    Web service references are not still added. But in my case I didn't want that, the only thing that is required is a servicereference in scriptmanager like this:

    <asp:ScriptManagerProxy ID="myProxy" runat="server">
            <Services>           
                <asp:ServiceReference Path="~/AdminServices/AccountAdmin.asmx" />
            </Services> 
            
        </asp:ScriptManagerProxy>

    and then calling methods like:

    MyWebForms.AdminServices.AccountAdmin.SearchUsersByPortionEU(passString, OnRequestCompleteSort, OnErrorSort);

    I copied this page from my previous project and I forgot to add script file "jquery.validate.js" and because of the logic of button clicks that were called after validation, the page got a full refresh and e.preventdefault was not called, so not working. after adding "jquery.validate.js" page worked.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 13, 2019 10:53 AM