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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:19:02+00:00 2026-06-12T04:19:02+00:00

I am facing a weird issues while fetching base64 encoded string sent from client

  • 0

I am facing a weird issues while fetching base64 encoded string sent from client to WCF Service at server. This string is always coming null in my WCF service method. The Business class I am having is:

[DataContract(Namespace = "")]
public class Test
{
    [DataMember]
    public int Id { get; set; }
    [DataMember]
    public int Name { get; set; }
    [DataMember]
    public int Age { get; set; }
    [DataMember]
    public string MyString { get; set; }
}

I am sending the post data in xml for to my WCF service:

    string data = string.Format("<Test><Id>{0}</Id><Name>{1}</Name><Age>{2}</Age><MyString>{3}</MyString></Test>",
        1, "name", 20, Convert.ToBase64String(image));//image is in bytes

Above “image” is in bytes.

While receiving the client data at server in MyTestService.svc.cs:

  public void CreateTest(Test test)
    {

in the “test” object I am getting the values of all properties which I sent from client except “MyString” property. It is always coming null. I double checked in Fiddler the “MyString” tag in xml contains the base64 encoded string. Can you help me fixing this?

Is there any limit for length of property value in xml tag. The encoded string of image is long enough.

  • 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-06-12T04:19:04+00:00Added an answer on June 12, 2026 at 4:19 am

    The DataContractSerializer (the default serializer for WCF) enforces the order of the elements in a data contract. If you don’t specify an order explicitly using the Order property of the [DataMember] attribute, the default order is alphabetical. Try sending the request in that order (Age, Id, MyString, Name), and you should see the value of MyString correctly populated.

    public class StackOverflow_12693581
    {
        [DataContract(Namespace = "", Name = "Test")]
        public class TestData
        {
            [DataMember]
            public int Id { get; set; }
            [DataMember]
            public string Name { get; set; }
            [DataMember]
            public int Age { get; set; }
            [DataMember]
            public string MyString { get; set; }
        }
        [ServiceContract]
        public interface ITest
        {
            [OperationContract]
            void Process(TestData test);
        }
        public class Service : ITest
        {
            public void Process(TestData test)
            {
                Console.WriteLine("MyString: {0}", test.MyString ?? "<<NULL>>");
            }
        }
        public static void Test()
        {
            string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            WebServiceHost host = new WebServiceHost(typeof(Service), new Uri(baseAddress));
            host.Open();
            Console.WriteLine("Host opened");
    
            byte[] image = Enumerable.Range(1, 100).Select(i => (byte)i).ToArray();
    
            WebClient c = new WebClient();
            Console.WriteLine("Order as in the question");
            string data = string.Format("<Test><Id>{0}</Id><Name>{1}</Name><Age>{2}</Age><MyString>{3}</MyString></Test>",
                1, "name", 20, Convert.ToBase64String(image));//image is in bytes 
            c.Headers[HttpRequestHeader.ContentType] = "text/xml";
            c.UploadString(baseAddress + "/Process", data);
            Console.WriteLine();
    
            c = new WebClient();
            Console.WriteLine("Correct order");
            data = string.Format("<Test><Age>{2}</Age><Id>{0}</Id><MyString>{3}</MyString><Name>{1}</Name></Test>",
                1, "name", 20, Convert.ToBase64String(image));//image is in bytes 
            c.Headers[HttpRequestHeader.ContentType] = "text/xml";
            c.UploadString(baseAddress + "/Process", data);
    
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
            host.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From this morning, I am facing weird issues with Rails devise. Following is output
I'm currently facing a weird problem while executing a command from my bash script.
This is a weird issue that I am facing while forms authentication. I am
Hi I started building apps with this technology and I am facing a weird
I am facing a weird problem. While browsing the C code of a project,
this time, I'm facing a really weird problem. I've the following code: $xml =
I'm facing a weird issue. I wrote a small server in C++ that stores
I am facing a weird issue: My source string for Html.fromHtml() is as follows:
i am facing a weird problem i am simply comparing two string values and
I'm facing this weird issue. I use the Character.reverseBytes(char ch) method for the purpose

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.