I am developing a web service that returns arrays of classes that I define in a web service. When I test it, I get: "System.InvalidOperationException: WebSite + HostHeader type was not expected. Use the XmlInclude or SoapInclude attribute to indicate types that are not statically known."
Here is the piece of code:
[WebService(Namespace = "http://WebSiteInfo.Podiumcrm.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebSite : System.Web.Services.WebService
{
public class WebSiteEntry
{
public string SiteName = "";
public string Comment = "";
public string IISPath = "";
public int SiteID = 0;
public ArrayList HostHeaders;
public WebSiteEntry()
{
}
}
public class HostHeader
{
public string IPAddress = "";
public int Port = 0;
public string URL = "";
public HostHeader()
{
}
}
[WebMethod(EnableSession = true)]
[TraceExtension(Filename = @"C:\DotNetLogs\WebSiteServices.log")]
public WebSiteEntry[] WebSites()
{...}
}
When I try:
[WebService(Namespace = "http://WebSiteInfo.Podiumcrm.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[XmlInclude(typeof(WebSiteEntry))]
[XmlInclude(typeof(WebSiteProperty))]
[XmlInclude(typeof(HostHeader))]
public class WebSite : System.Web.Services.WebService
{...}
I get: "The type or name of the XmlInclude namespace could not be found (are you missing the using directive or assembly references?)"
Indicates a person who can give me a spell that compiles and executes!
Thanks...
source
share