c# - .net / wcf: deserialization of an xml with xsi:type -
I have a small WCF server that received a post request with XML (note that I have no control over XML is). I can not deserialize it with any problem unless it is a xsi: type = "something" attribute
Whenever I try to sort my class, anything works (Even XSI: type attribute).
XML:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Node1 Att1 = "" Att2 = "" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" XSI: type = "SOMETHING" xmlns = "http: //www.CIP4Org / JDFSchema_1_1 "xmlns: xsd =" http://www.w3.org/2001/XMLSchema "& gt; & Lt; Node2 / & gt; & Lt; / Node1 & gt; When I send this XML, the server throws a bad request (400), but if I remove "xsi: type =" SOMETHING ", then ever works .
What does the server send when I ask for a serialized class:
If the serialization works well, why not do deserialization?
Here's my class:
using the system; Using System.Collections.Generic; Using System.Linq; Using System.Text; Using System.ServiceModel; Using System.Xml.Serialization; Using System.Xml.Schema; Namespace Console Application Test.dom {[Serializable ()] [XmlRoot (ElementName = "Node1", Namespace = "http://www.CIP4.org/JDFSchema_1_1")) Public Class Test {// Feature [XmlAttribute ("Att1 "]] Public string Att1 =" "; [XmlAttribute ("AT2")] Public string Att2 = ""; [XmlAttribute ("Type", Namespace = "http://www.w3.org/2001/XMLSchema-instance")) Public String Type = "Type Typing"; [XmlElement ("node 2")] public string node2 = ""; }} Please help me: (
this class Try the following:
[Serialable] [XmlRoot (ElementName = "node 1", namespace = "http://www.CIP4.org/JDFSchema_1_1")) Public class SOMETHING {/ Public String Att2 = "" [XmlElement ("Node2")] public string node2 = "";} P> My code works fine XmlSerializer ser = new XmlSerializer (typef (some)); Some T = (some) ser.Deserialize (new system .oo string reader (textbox1. Text));
Comments
Post a Comment