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 409865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:49:56+00:00 2026-05-12T17:49:56+00:00

I am creating a Web Service using ASP.NET C#. I am sending various data

  • 0

I am creating a Web Service using ASP.NET C#. I am sending various data types from the webservice so I use the following structure.

public enum WS_ServiceResponseResult
{
    Success,
    Failure,
}
public class WS_ServiceResponse
{
    public WS_ServiceResponseResult result { get; set; }
    public object data { get; set; }
}

public class WS_User
{
    public long id{ get; set; }
    public string name{ get; set; }
}

Webservice Sample Method

    [WebMethod(EnableSession = true)]
    public WS_ServiceResponse LogIn(string username, string pasword)
    {
        WS_ServiceResponse osr = new WS_ServiceResponse();
        long userID = UserController.checkLogin(username, pasword);

        if (userID != 0)
        {
            osr.result = WS_ServiceResponseResult.Success;
            osr.data = new WS_User() { id = userID, name = username };
        }
        else
        {
            osr.result = WS_ServiceResponseResult.Failure;
            osr.data = "Invalid username/password!";
        }
        return osr;
    }

I am using two client types, javascript and C#.NET Windows Form. When I call from javascript I get no problem and the osr.data is filled with WS_User. So i can use osr.data.id easily. But when I use from C#.NET (proxy is generated using “Add Web Reference”) I can successfully call but when the result arrives I get a Soap Exception

{System.Web.Services.Protocols.SoapException:
System.Web.Services.Protocols.SoapException:
Server was unable to process request.
—> System.InvalidOperationException: There was an error generating the XML
document. … …

What am I missing? I Guess object is not well defined and causing the problems. What are the workarounds?

Thanks

Maksud

Addition:

If add the following dummy method, then it works nicely. Hope it helps, to get the solution.

    [WebMethod]
    public WS_User Dummy()
    {
        return new WS_User();
    }
  • 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-12T17:49:57+00:00Added an answer on May 12, 2026 at 5:49 pm

    I had a similar Problem returning an “object” (multiple classes possible)
    Here is a sample code:

    [Serializable()]
    [XmlRoot(ElementName="Object")]
    public sealed class XMLObject
    {
    
        private Object _Object;
    
        [XmlElement(Type=typeof(App.Projekte.Projekt), ElementName="Projekt")]
        [XmlElement(Type=typeof(App.Projekte.Task), ElementName="Task")]
        [XmlElement(Type=typeof(App.Projekte.Mitarbeiter), ElementName="Mitarbeiter")]
        public Object Object
        {
            get
            {
                return _Object;
            }
            set
            {
                _Object = value;
            }
        }
    }
    

    I think you should change your code this way:

    [XmlRoot(ElementName="ServiceResponse")]
    public class WS_ServiceResponse
    {
        public WS_ServiceResponseResult result { get; set; }
    
        [XmlElement(Type=typeof(WS_User), ElementName="WS_User")]
        [XmlElement(Type=typeof(string), ElementName="Text")]
        public object data { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF ASP.Net 4.0 web service we'll call WebService. WebService is consuming
We are creating ReST Web Services using ASP.NET and OpenRasta. Is there any tool
Is there a way when creating web services to specify the types to use?
I am creating a large ASP.NET 4 site which has a WCF service backend.
I'm creating a REST web service using spring and I need to implement login/logout
We're creating a web system using Java and Servlet technology (actually Wicket for the
I am working on creating a .asmx webservice to meet the specific needs of
If I was a webservice, such as Twitter, how does creating an API for
When creating web parts for Sharepoint, is it better to create an actual web
When creating web pages how do we achieve a consistent font size across browsers.

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.