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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:49:03+00:00 2026-05-23T15:49:03+00:00

My soap service receives a XML and i need to add soap enevelope to

  • 0

My soap service receives a XML and i need to add soap enevelope to the xml before i send it to a HTTP service, i get a error at
line httpDocumet.DocumentElement.AppendChild(xml.DocumentElement);

how can i append soap headers to my xml?

    [WebMethod]
    public XmlDocument HelloWorld(XmlDocument xml)
    {

        XmlDocument httpDocumet = new XmlDocument();
        XmlElement soapEnvelope = httpDocumet.CreateElement("soap", "Header", "http://schemas.xmlsoap.org/soap/envelope/");
        soapEnvelope.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        soapEnvelope.SetAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
        httpDocumet.AppendChild(soapEnvelope);
        XmlElement soapBody =httpDocumet.CreateElement("soap", "Body", "http://schemas.xmlsoap.org/soap/envelope/");
        httpDocumet.DocumentElement.AppendChild(soapBody);
        httpDocumet.DocumentElement.AppendChild(xml.DocumentElement);

ERRROR MSG

System.Web.Services.Protocols.SoapException:
Server was unable to process request.
—> System.ArgumentException: The node to be inserted is from a
different document context. at
System.Xml.XmlNode.AppendChild(XmlNode
newChild) at
WebService1.Service1.HelloWorld(XmlDocument
xml)

  • 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-23T15:49:03+00:00Added an answer on May 23, 2026 at 3:49 pm

    You need to first ImportNode and then AppendChild.

    var root = httpDocument.ImportNode(xml.DocumentElement, true);
    httpDocument.DocumentElement.AppendChild(root);
    

    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.importnode.aspx

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

Sidebar

Related Questions

While consuming SOAP service, I am getting this error. I just dun get it
I need some help posting some XML to a WCF service. In essence, the
I have a WCF service reference: http://.../Service.svc(?WSDL) and I have an XML file containing
I need to get the SOAP message from exchange object I receive in my
I've written a SOAP service so my Silverlight application can add entires into my
I am executing a method of a SOAP web service which receives 3 string
I've managed to parse xml responses from a SOAP web service when I receive
I have a problem calling a SOAP Web Service. When I send my signed
I am posting a xml to web service created in ASP.net using SOAP and
can i implement a SOAP Service which can deal with delegates/events?? Can i also

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.