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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:27:41+00:00 2026-06-14T02:27:41+00:00

Concise…object returned from webservice call gets mangle with additional bytes in my conversion function.

  • 0

Concise…object returned from webservice call gets mangle with additional bytes in my conversion function.

Basically I have a webreference that I send an XDocument to

    System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
    Byte[] baXml = encoding.GetBytes(xdoc.ToString());

    object o = MEF_Test.NewSubmission("*********", "*********", baXml);

The transmission is successful and I get back what I assume is the xml document and I am trying to go back to an XDocument. I convert my object to a byte array

    Byte[] baResponse = ObjectToByteArray(o);

I put this function in at the bottom but it may be where there error is at

The object I get back is 10492 characters but gets bigger by 28 bytes to the size of 10520 after conversion

            string ss = Encoding.UTF8.GetString(baResponse);
            string ss1 = ss.Substring(28);
            XDocument xSubmissionResponse = XDocument.Parse(ss1);

In the screenshot you can see the extra characters and I attempt to get past them by getting the substring past them. The string then looks good but then throws an exception about a hexadecimal value 0x0B further ahead in the string.

Can anyone give this a look? Thanks.

—Screenshot with as much info as possible

I don’t have the reputation to stick the image in I hope the link works.

    private static byte[] ObjectToByteArray(Object obj)
    {
       if (obj == null)
          return null;
       BinaryFormatter bf = new BinaryFormatter();
       MemoryStream ms = new MemoryStream();
       bf.Serialize(ms, obj);
       return ms.ToArray();
    }
  • 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-14T02:27:42+00:00Added an answer on June 14, 2026 at 2:27 am

    o is already an array of bytes (as seen in the debugger). Deserializing it again makes no sense. Just cast object o to byte[] and then run the Encoding.GetString method on it.

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

Sidebar

Related Questions

Coming from Haskell I was used to have concise operators like not (x `elem`
I'm looking for a concise and functional style way to apply a function to
I am looking for a concise JavaScript function which takes some values and returns
Here's a concise example: x.py: class x: var = 'from x.py' y.py: class x:
Is there a concise way to implement the following design pattern? function a() {
Sorry about the in-concise title. I have an Android app in which I draw
I'll make it more concise as possible: I have Eclipse Indigo SR2 with ADT
I want to write the function below in a more concise manner: def sum_list(l):
What is the most concise/efficient function (in C++) to convert a cyclic index in
Does anyone have a link to a concise summary of what makes a portlet

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.