88080

Read an XML file in a WCF service and return XML from the service

I need to read an XML file in my WCF service and return the same file as XML back from my WCF service in C#. Can someone point me to the right direction. Most samples out there seems outdated.

Answer1:

I believe you can just return XmlElement (for example, the root element) and it'll work?

[OperationContract] XmlElement GetXml(string path); ... public XmlElement GetXml(string path) { var doc = new XmlDocument(); doc.Load(path); // TODO: add security... return doc.DocumentElement; }

Recommend

  • How parse xml using jaxb
  • How to config WebService to return ArrayList instead of Array?
  • Deserialize XML in a WP8 Application
  • Stripe - PHP error - Stripe no longer supports API requests made with TLS 1.0
  • Why doesn't MSHTML for .Net have querySelector and querySelectorAll, or where are they?
  • Rapidly iterating Silverlight development
  • SQL multiple SELECT query with xmlagg function- Data not pulled in the required fashion
  • How to store pointer to S3 objects in Amazon SimpleDB?
  • Visual Studio extension: Change the hint path of an assembly reference
  • Imagemagick set interline spacing?
  • Finding number of samples in a .wav header
  • how to calculate distance between two points in google maps?
  • Put percent labels next to legend instead of in the slice
  • HABTM associations in Rails : collecting and counting the categories of a model's children
  • Is mp4 stream able with ffserver?
  • Guava how to copy all files from one directory to another
  • JBoss External Properties Files in Classpath
  • C: Incompatible pointer type initializing
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • htaccess add www if not subdomain, if subdomain remove www
  • Play WS (2.2.1): post/put large request
  • Android screen density dpi vs ppi
  • Jenkins: How To Build multiple projects from a TFS repository?
  • How would I use PHP exceptions to define a redirect?
  • How to extract text from Word files using C#?
  • Deserializing XML into class C#
  • Weird JavaScript statement, what does it mean?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Is there a mandatory requirement to switch app.yaml?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • need help with bizarre java.net.HttpURLConnection behavior
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • Django query for large number of relationships
  • How can i traverse a binary tree from right to left in java?
  • How to Embed XSL into XML