xml-serialization

XmlSerializer.Deserialize blocks over NetworkStream

I'm trying to sends XML serializable objects over a network stream. I've already used this on an UDP broadcast server, where it receive UDP messages from the local network. Here a snippet of the server side: while (mServiceStopFlag == false) { if (mSocket.Available > 0) { IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any...

Receiving XML from Actionscript on Servlet - Invalid Stream Header

I have an ActionScript File sending XML to my servlet. I am only getting empty arrays on output. In ActionScript I checked and I am in fact sending the correct XML. Anyone know what Exactly I'm doing wrong? Exception error is: java.io.StreamCorruptedException: invalid stream header package myDungeonAccessor; try { Sys...

Unknown attribute xsi:type in XmlSerializer

I am learning XML Serialization and meet an issue, I have two claess [System.Xml.Serialization.XmlInclude(typeof(SubClass))] public class BaseClass { } public class SubClass : BaseClass { } I am trying to serialize a SubClass object into XML file, I use blow code XmlSerializer xs = new XmlSerializer(typeof(Base)); xs.Serialize(fs, ...

How to use xml response as XMLObject outside of ajax callback function

Hopefully I've just made a dumb oversight, but I can't figure out why the following doesn't work: $(function() { var xml; $.get( "somexml.xml", function(data){ xml = data; }, "xml"); alert(xml); }); If I put the alert inside of the callback function, I get back object XMLdocument but...

If you use XML Serialization how do you validate data?

Hi I am planning to try to use XML Serialization in C# but I am wondering if I get a .xml file how do I check if the xml file confirms to the right type? Like usually you would make a schema that you can validate against to make sure if it confirms to the right format. Can you hook a schema up to to XML Serialization or does it do thi...

Reading and writing XML over an SslStream

I want to read and write XML data over an SslStream. The data (written and read) consists of objects serialized by an XmlSerializer. I have tried the following; (left some details out for clarity!) TcpClient tcpClient = new TcpClient(server, port); SslStream sslStream = new SslStream(tcpClient.GetStream(), true, new RemoteCertificateVa...

XSD.exe doesn't enforce minOccurs

I have a simple schema where I'm declaring both minOccurs and maxOccurs to 1. When I run the XSD.exe to generate a C# class and consume the class in code; the field is not enforced as mandatory. Is there some additional step missing? or does the classes generated using XSD.exe don't mandatory fields? any suggestions or insight will be h...

How do I make a serialization class for this?

I have something like this (sorry for the bad names) <?xml version="1.0" encoding="utf-8" ?> <root xmlns="http://www.domain.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.domain.com Schema.xsd"> <product></product> <SomeHighLevelElement> <anotherElment> ...

Why is XML Deserilzation not throwing exceptions when it should.

Hi Here is some dummy xml and dummy xml schema I made. schema <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.domain.com" xmlns="http://www.domain.com" elementFormDefault="qualified"> <xs:element name="vehicles"> <xs:complexType> <xs:sequence> ...

Using Svcutil to create proxy class does not include XmlIgnore attribute

Is there a way to have SvcUtil include the [XmlIgnore] attribute? we need this attribute in our proxy classes (because we have Dictionaries that XmlSerialization does not like), but SvcUtil does not include these attributes in the generated proxies. ...

Serialize into an XML Fragment - not XML Document

How do I serialize an XML-serializable object to an XML fragment (no XML declaration nor namespace references in the root element)? ...

How can I determine whether xml serializer can serialize a file

Hi, How can I determine whether xml serializer can serialize a file which is in a shared location and monitored by a file monitor. The file monitor has a list of parsers which are used to parse files in the shared folder. Once a file gets dropped into the folder, the file monitor will ask the registered parsers whether any of them can...

How do I return pure XML from asmx web service?

I want an asmx webservice with a method GetPeople() that returns the following XML (NOT a SOAP response): <People> <Person> <FirstName>Sara</FirstName> <LastName>Smith</LastName> </Person> <Person> <FirstName>Bill</FirstName> <LastName>Wilson</LastName> </Person> </People> How can I d...

xmlns='' was not expected when deserializing nested classes

I have a problem when attempting to serialize class on a server, send it to the client and deserialize is on the destination. On the server I have the following two classes: [XmlRoot("StatusUpdate")] public class GameStatusUpdate { public GameStatusUpdate() {} public GameStatusUpdate(Player[] players, Command command) ...

C# encrypt whole XML File

I already have a solution for encrypting of several XML nodes or strings. But of course, you can open the local saved XML file and you should see the node tags. For some intelligent people it could be a reference for hidden informations. Is there any way to encrypt and decrypt the whole xml content including all node tags? ...

Special characters in XHTML - Parse Error

When there are special characters like & in the xhtml the DOM / SAX parser throws parse exception. The xhtml document is got as an input for my component. I want to ignore such special characters when i parse. How can i achieve it using DOM/SAX JAVA parser. ...

XML serialization options in .NET

I'm building a service that returns an XML (no SOAP, no ATOM, just plain old XML). Say that I have my domain objects already filled with data and just need to transform them to the XML format. What options do I have on .NET? Requirements: The transformation is not 1:1. Say that I have an Address property of type Address with nested pr...

WCF XmlSerializer split files

I have a client's wsdl and xsds files for java webservices. I am using svcutil (XmlSerializer) to generate the client side proxy classes. I had to make a few tweaks to the wsdl's (which I told the client about) to make svcutil work but now it generates one 11.2MB file which compiles into a 3.7MB dll. Is there any way to have svcutil spli...

How to transport an XML fragment in an XML Document

Hi, I'm using an AJAX system on a web application, and for one of the objects i return, it needs to contain an xml fragment. Unfortunately, being AJAX, i'm sending the values back via XML already. So, at the moment, i have something that looks like this (ignoring the fact the tags arent perfect. <Transport> <Message> <Conte...

Nservicebus serization issue of derived types

Hi Guys, for the context setting, I am exchanging messages between my nServiceBus client and nSerivceBus server. its is the namespace xyz.Messages and and a class, Message : IMessage I have more messages that are in the other dlls, like xyz.Messages.Domain1, xyz.Messages.Domain2, xyz.Messages.Domain3. and messages that derive form tha...