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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:41:06+00:00 2026-06-12T14:41:06+00:00

This is a continuation of my previous question regarding the Expect100Continue Header not being

  • 0

This is a continuation of my previous question regarding the Expect100Continue Header not being able to be removed in Windows Store apps, for reference: ServicePoint.Expect100Continue for Windows Store Apps

I stepped back now and am now using the HttpClient to manually POST HttpContent to the Webservice. I am using classes like this:

[XmlRoot(ElementName = "myRootElement", Namespace = "myNamespace.com")]
public class MyRootElement
{
     [XmlElement(Namespace = "myNamespace.com", ElementName = "myParameter")]
     public string MyParameter { get; set; } 
}

To serialize and construct the body of the HttpContent, i am using serialization code like this:

using (MemoryStream stream = new MemoryStream())
{
       XmlWriterSettings settings = new XmlWriterSettings();
       settings.OmitXmlDeclaration = true;
       settings.Encoding = Encoding.UTF8;
       settings.Indent = false;
       settings.NamespaceHandling = NamespaceHandling.Default;

       XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
       ns.Add("", "myNamespace.com");

       using (XmlWriter xmlWriter = XmlWriter.Create(stream, settings))
       {
           XmlSerializer ser = new XmlSerializer(input.GetType());
           ser.Serialize(xmlWriter, input, ns);
       }

       var arr = stream.ToArray();
       body = Encoding.UTF8.GetString(arr, 0, arr.Length);
   }

   var result = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
            body
            + "</s:Body></s:Envelope>";

However the output is flawed. The namespace is only written at the root element but not on the parameter element. There is a “?” character at the beginning of body i am unable to remove or find the source of.

Also i’d like to know if there is a better way then string concatonation to enclose the body in a SOAP envelope.

  • 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-12T14:41:07+00:00Added an answer on June 12, 2026 at 2:41 pm

    Solved the “?” issue by replacing the MemoryStream with a StringBuilder. The namespace issues where resolved by using two different namespaces for the XmlRoot and the XmlElements. It feels clunky and unnecessary complicated but “it works”.

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

Sidebar

Related Questions

This is a continuation of my previous question: Could not find an implementation of
This is a continuation of my previous question .NET regex engine returns no matches
This question is a continuation of my previous question here zend models architecture (big
This question is in continuation to my previous question . I am trying to
This is in continuation to my previous question which was closed cause of similarity
This is a continuation of my previous question which I posted when I wasn't
This question is in continuation to my previous question, in which I asked about
This is a continuation from a previous stackoverflow question. I've renamed some variables so
This question is a continuation of a previous thread to compare two lists with
This question is in continuation to my previous post located here . Since there

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.