datacontractserializer

XSLT Transform XML with Namespaces

我的梦境 提交于 2019-11-27 06:48:30
I'm trying to transform some XML into HTML using XSLT . Problem: I can't get it to work. Can someone tell me what I'm doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.test.com/"> <Brokerage> <BrokerageID>91</BrokerageID> <LastYodleeUpdate>0001-01-01T00:00:00</LastYodleeUpdate> <Name>E*TRADE</Name> <Validation i:nil="true" /> <Username>PersonalTradingTesting</Username> </Brokerage> </ArrayOfBrokerage> XSLT: <xsl:stylesheet version="1.0" xmlns="http://www.test.com/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3

“Type not expected”, using DataContractSerializer - but it's just a simple class, no funny stuff?

北战南征 提交于 2019-11-27 05:23:30
I'm refactoring my XML-serialization, and figured I'd try the DataContractSerializer. Everything runs smoothly, until it needs to serialize this class: using System; using System.Runtime.Serialization; namespace VDB_Sync.Model { [DataContract(Name="Konstant")] public class Konstant : DataFelt { [DataMember] private MySqlDbType mydataType; [DataMember] private object value; public Konstant(string navn, MySqlDbType dataType, object value) : base(navn, dataType, "*Konstant", false, false) { //this.navn = navn; this.mydataType = dataType; this.value = value; if (navn.Contains("*Løbenummer")) {

Serializing object with no namespaces using DataContractSerializer

╄→尐↘猪︶ㄣ 提交于 2019-11-27 01:01:02
问题 How do I remove XML namespaces from an object's XML representation serialized using DataContractSerializer? That object needs to be serialized to a very simple output XML. Latest & greatest - using .Net 4 beta 2 The object will never need to be deserialized. XML should not have any xmlns:... namespace refs Any subtypes of Exception and ISubObject need to be supported. It will be very difficult to change the original object. Object: [Serializable] class MyObj { string str; Exception ex;

Why doesn't the XmlSerializer need the type to be marked [Serializable]?

血红的双手。 提交于 2019-11-26 22:41:24
In C#, if I want to serialize an instance with XmlSerializer , the object's type doesn't have to be marked with [Serializable] attribute. However, for other serialization approaches, such as DataContractSerializer , needs the class be marked as [Serializable] or [DataContract] . Is there any standard or pattern about serialization requirement? This is because XmlSerializer only serializes public fields/properties. Other forms of serialization can serialize private data, which constitutes a potential security risk, so you have to "opt in" using an attribute. Security isn't the only issue;

WCF chokes on properties with no “set ”. Any workaround?

别来无恙 提交于 2019-11-26 22:36:54
问题 I have some class that I'm passing as a result of a service method, and that class has a get-only property: [DataContract] public class ErrorBase { [DataMember] public virtual string Message { get { return ""; } } } I'm getting an exception on service side: System.Runtime.Serialization.InvalidDataContractException: No set method for property 'Message' in type 'MyNamespace.ErrorBase'. I have to have this property as only getter, I can't allow users to assign it a value. Any workaround I could

Data Contract Serializer - How to omit the outer element of a collection

白昼怎懂夜的黑 提交于 2019-11-26 21:03:08
How do I serialize a list without the outer element using the Data Contract Serializer? I am using .Net 3.5. I have a class that contains a list, amongst other things, that I wish to serialize without the outer element to be compliant with the pertinent XSD: [DataContract(Name="MyClass")] public class MyClass { ... [DataMember(Name="Parameters")] public List<Parameter> Parameters; ... } [DataContract(Name="Parameter")] public struct Parameter { [DataMember(Name="ValueName")]string ValueName; [DataMember(Name="Value")]int Value; public Parameter(string ValueName, int Value) { this.ValueName =

Generic WCF JSON Deserialization

跟風遠走 提交于 2019-11-26 20:17:39
问题 I am a bit new to WCF and will try to clearly describe what I am trying to do. I have a WCF webservice that uses JSON requests. I am doing fine sending/receiving JSON for the most part. For example, the following code works well and as expected. JSON sent: { "guy": {"FirstName":"Dave"} } WCF: [DataContract] public class SomeGuy { [DataMember] public string FirstName { get; set; } } [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat =

DataContractSerializer is an opt-in serializer. How to make it Opt-Out?

老子叫甜甜 提交于 2019-11-26 18:38:59
问题 I inherited some classes with a large number of attributes. I want to be able to serialize them for WCF . As DataContractSerializer is an opt-in serializer, I will need to decorate all the properties with DataMember attribute, which seems to me a little cumbersome. Don't I have any other way around so that I don't have to add DataMember to all the properties? Please note, most of my properties need to be serialized. 回答1: It depends if your properties can be automatically generated - if so,

WCF Datacontract, some fields do not deserialize

北城余情 提交于 2019-11-26 17:53:59
Problem: I have a WCF service setup to be an endpoint for a call from an external system. The call is sending plain xml. I am testing the system by sending calls into the service from Fiddler using the RequestBuilder. The issue is that all of my fields are being deserialized with the exception of two fields. price_retail and price_wholesale . What am I missing? All of the other fields deserialize without an issue - the service responds. It is just these fields. XML Message: <widget_conclusion> <list_criteria_id>123</list_criteria_id> <list_type>consumer</list_type> <qty>500</qty> <price_retail

Is there a way to make DataContractSerializer output cleaner XML?

自古美人都是妖i 提交于 2019-11-26 17:00:26
问题 Using the DataContractSerializer to serialize my object I get an output similar to <?xml version="1.0" encoding="utf-8" ?> <AgentNotification xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/The.name.space.Notifications"> <_x003C_Created_x003E_k__BackingField i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/The.name.space" /> <_x003C_Id_x003E_k__BackingField i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/The.name.space"