0

I am developing a WCF SOA(ish) architecture application that I needs to receive and return XML.

I have scoured the net for best practices. The only thing I know is sending raw xml as a string is going to cause problems.

I was therefore looking at an XmlTextReader type object that could perhaps be more elegantly marshalled from a to b and then back.

I get an error when i try and call my service that takes a XmlTextReader as a type and frankly it is confusing the hell out of me.

Bottom line it needs to accept and recieve large amounts of xml and I can't/don't want to use my own definded types.

Any help?

Jon H
  • 1,061
  • 4
  • 13
  • 32
  • 2
    The web doesn't have all the answers...(for free that is). You should consider investing in a C# XML book such as "Beginning XML with C# 2008: From Novice to Professional" or "Beginning C# XML: Essential XML Skills for C# Programmers". You really should know what you're doing if you plan on reading/writing a ton of xml in C#. Also as you're in .net 4, you may want to read up on LINQ. See http://stackoverflow.com/questions/55828/best-practices-to-parse-xml-files for a related question. – Eugene Oct 19 '11 at 16:24
  • Damn books :) I know I know I must get savvy but da bawz wants it yesterday! Nearly perfect is perfect enough :) Thanks tho! – Jon H Oct 20 '11 at 07:41

2 Answers2

0

One answer without deeper analysis : you could maybe convert XML to Base64 encoded string and send it like that.

Goran Genter
  • 159
  • 4
  • Hmm still might have a size issue.. I don't have a problem processing once it gets there but for some reason it won't marshal the XmlTextReader I just get 'Object reference not set to an instance of an object.' no evidence that this type can't be marshalled. – Jon H Oct 19 '11 at 16:36
  • I wouldn't do that in your place, because even if you get it working your service won't work on other platforms. Why would you have size issues with base64? How big is your xml? – Goran Genter Oct 19 '11 at 16:39
  • Well the XML I am returning from my service will easily breach the 8k limit on a string. I just don't want to return home grown complex data types as I could not say who or what might be calling the service. Hence my exploration of a framework XML Container. Damn XML it is so verbose. – Jon H Oct 20 '11 at 07:40
  • 1
    You can always compress it and return in string a compressed version of XML (converted to Base64). Also, you can easily increase the string size by changing the maxStringContentLength in Binding definition. It's not a big and complex issue. – Goran Genter Oct 22 '11 at 08:41
0

You could use XElement - personally have only used this on relatively small chunks of Xml - YMMV.

seanb
  • 6,969
  • 2
  • 33
  • 34