locked
Error with Webservice RRS feed

  • Question

  • User-374939276 posted

    I am getting this error with my webservice.  If I remove the method at the bottom, the error goes away.  Any ideas?  Thanks!: System.InvalidOperationException: AjaxAuction cannot be serialized because it does not have a parameterless constructor.

    public class AuctionLatestBidder : System.Web.Services.WebService
    {
    
        public AuctionLatestBidder() { }
    
        [WebMethod]
        [System.Web.Script.Services.ScriptMethod(UseHttpGet = true, ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
        public string HelloWorld()
        {
            return DateTime.Now.ToString();
        }
    
        [WebMethod]
        [System.Web.Script.Services.ScriptMethod(UseHttpGet = true, ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
        public string HelloWorldID(string id)
        {
            return DateTime.Now.ToString() + id;
        }
    
        [WebMethod]
        public AjaxAuction GetAjaxAuctionDetails(string _auctionID)
        {
            int auctionID = Int32.Parse(_auctionID);
            AjaxAuction auction = new AjaxAuction(auctionID);
            return auction;
        }
    }


    Tuesday, July 23, 2013 1:42 AM

Answers

  • User-1360095595 posted

    Sounds like you need to add a parameterless constructor to AjaxAuction class. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 23, 2013 1:48 AM

All replies

  • User-1360095595 posted

    Sounds like you need to add a parameterless constructor to AjaxAuction class. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 23, 2013 1:48 AM
  • User-374939276 posted

    Thanks!

    Tuesday, July 23, 2013 2:07 AM