locked
XML element references a method and a type RRS feed

  • Question

  • User-915495541 posted

    The following code works:

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class WebService1 : WebService
    {
        [WebMethod]
        public GetResultReportResponse GetResultReport(GetResultReportRequest request)
        {
            return new GetResultReportResponse();
        }
    }
    
    public class GetResultReportRequest
    {
    }
    
    public class GetResultReportResponse
    {
    }



    but this variant does not:

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class WebService1 : WebService
    {
        [WebMethod]
        public GetResultReportResponse GetResultReport(string request)
        {
            return new GetResultReportResponse();
        }
    }
    
    public class GetResultReportRequest
    {
    }
    
    public class GetResultReportResponse
    {
    }
    }


    The second one yields the message "The XML element 'GetResultReportResponse' from namespace 'http://tempuri.org/' references a method and a type." I know I can get around this by setting MessageName on the WebMethodAttribute but I don't understand why this happens.

    Anyone, please?

    Wednesday, March 27, 2013 3:26 PM

All replies

  • User220959680 posted

     public GetResultReportResponse GetResultReport(string request)
        {
            return null;
        }
    }
    
    public class GetResultReportRequest
    {
    }
    
    public class GetResultReportResponse
    {
    }

    The second one yields the message "The XML element 'GetResultReportResponse' from namespace 'http://tempuri.org/' references a method and a type."

    The web method should return type of GetResultReportResponse NOT null.

    Thursday, March 28, 2013 7:15 AM
  • User-915495541 posted

    Thank you for answering. But, the null thing has nothing to do with it. It is just sample code to prove a point. I have changed the code samples to avoid confusion.

    Thursday, March 28, 2013 11:44 AM