Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3457626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:53:00+00:00 2026-05-18T09:53:00+00:00

I have an ASMX webservice with a number of methods which will return XML.

  • 0

I have an ASMX webservice with a number of methods which will return XML.

The service returns various different objects and I have created a wrapper object which contains information about the request e.g:

[Serializable]
[XmlRoot("response")]
public class DtoWrapper<T>
{
    [XmlElement("error")]
    public bool Error { get; set; }

    [XmlElement("error_message")]
    public string ErrorMessage { get; set; }

    [XmlElement("success")]
    public bool Success { get; set; }

    [XmlElement("friendly_message")]
    public string FriendlyMessage { get; set; }

    [XmlArray("result")]
    [XmlArrayItem("item")]
    public List<T> Payload { get; set; }
}

Now this works fine until I defined my second method with a different type. Then I get this error when I try and load the ASMX test page

The top XML element ‘response’ from namespace ‘http://tempuri.org/&#8217;
references distinct types
MyProject.Web.webservices.DtoWrapper1[MyProject.BusinessLogic.ClassA]
and
MyProject.Web.webservices.DtoWrapper
1[MyProject.BusinessLogic.ClassB].
Use XML attributes to specify another
XML name or namespace for the element
or types.

I have tried marking my objects up with [XmlType(Namespace="com.temp.A")] and [XmlType(Namespace="com.temp.B")] but it doesn’t seem to help.

Any ideas? Will I have to create a wrapper object for each type I want to use?

EDIT: I’ve realised it’s not actually the type arguments that are the problem. It’s the fact that the [XmlRoot] tag is specified on the class. The serializer is treating them as 2 types but they have the same root element in the same namespace.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:53:00+00:00Added an answer on May 18, 2026 at 9:53 am

    You cannot do this. XML has no concept of generics, neither do XML Schema or SOAP. As far as XML Schema is concerned, if it has the same element name and same namespace, then it’s the same thing.

    You cannot have a generic web service, as the concepts do not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written an ASMX service that looks like thus; namespace AtomicService { [WebService(Namespace
I have a webservice (asmx file) in a directory requiring form authentication When I
Say I have an ASMX web service, MyService. The service has a method, MyMethod.
Why is that Web Service files (.asmx) have their code-behind placed in app_code folder
I have a web service (ASMX) and in it, a web method that does
I have a web service (WCF or ASMX doesn't matter)... I have made a
I have an .asmx in a folder in my application and I keep getting
We have a typical business application with an Outlook-looking Winforms client talking to asmx
I have an asp.net website and a windows form application. My Webservice's Location is
I'm getting an exception when trying to access an .asmx webservice within a MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.