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

  • SEARCH
  • Home
  • 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 901705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:35:54+00:00 2026-05-15T15:35:54+00:00

Is it possible for a .NET web service to accept an immutable object (or

  • 0

Is it possible for a .NET web service to accept an immutable object (or an object containing references to immutable objects) in a web method?

For example, if this is my web service method:

public class MyWebService : System.Web.Services.WebService
{
    [WebMethod]
    public void SetStatus(StatusData data)
    {
        // do something
    }
}

and StatusData contains an immutable property, Server will throw a System.Web.Services.Protocols.SoapException when method is called:

Unable to generate a temporary class (result=1).
Error CS0200: Property or indexer ‘TestProject.Entities.StatusData.Id’ cannot be assigned to — it is read only

Can I still use immutable objects somehow, or is the only way to do it to map everything into mutable DTOs?

[Edit]

Obviously, I am not talking about strings, since string is a base type in .Net, and is really an exception to this problem. For example, XmlSerializer will not work (without explicit IXmlSerializable implementation) for any other immutable class.

But I was hoping that I could avoid manually writing a bunch of mutable DTOs (although the actual mapping can be automated).

  • 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-15T15:35:54+00:00Added an answer on May 15, 2026 at 3:35 pm

    Well, it seems that there is no way but to use mutable DTOs for SOAP, so we used DTOs and AutoMapper to convert from immutable objects automatically.

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

Sidebar

Related Questions

I wanted to know it is possible to call a hosted .net web service
I'm using jquery to access a asp.net web service from my website. This web
For this question, I'm using ASP.NET Web Forms in C#, a web service and
Is it possible to have a web service within an ASP.NET forms web site
Is it possible to develop an ASP.NET Web Service using the Visual Web Developer
Is it possible in .net 2.0 to enable calling web service only from localhost
Possible Duplicate: VS 2010 Web Service project template missing? I'm wondering why Asp.Net Web
Is it possible to make the auto-generated WSDL for a .NET web service include
I have the following .NET web service with the following signature (IServices.cs): [OperationContract] [WebInvoke(Method
I have a C# ASP.NET web service running (successfully) on this PC. I can

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.