wcf - How to serialize a subclass using DataContracts -


I have just started a WCF project programming and have a serialization problem that I can not fix. I am using Data Contracts and Datamomers to serialize my classes into XML.

I have a class TestResponse which contains a property TestParameter This property contains a string parameter. Also, I have a sub class of TestParameter named "TestParameterSubclass" . I need to sort this subcategory. These three squares look like this:

TestResponse.cs

  [DataContent (namespace = service) Default namespace, name = "test response")] Public Category TestResponse {{Database (name = "Test Pimentator")} Public Test Parameters Ultimate (Receive); Set; }}  

TestParameter.cs

  [DataContent (namespace = service. Default namespace, name = "test pammR") ] [Known Type (TestParameterSubclass)] Public Class TestParameter {[DataMember (name = "ParamName")] Public String Paramine {get; PublicPrintParameterSubclass: TestParameter (Set);}}  

TestParameterSubclass.cs

  [DataContract (name = "TestParameterSubclass I have an Operation Contract. [Operation Contract] [WebInvoc (method = "Post", Response Format = WebmailFormat.xml, Request format = webmail format.axm, bodystyle = webmailbodystyle.bare, uritapplet = "/ calculation a")] test response calculatee (testrojest data);  

and CalculateA

  Public TestResponse CalculateA (TestRequest Request) {TestResponse tr = new TestResponse (); TestParameterSubclass parameter subclass = new TestParameterSubclass (); Tr.param = parameterSubclass; Tr.param.ParamName = "is"; Return TR; }  

resulting in

   

However, I need XML to use the subclass name as the element name, such as

   

Does anyone know this?

(I have a similar problem for DSRiling the input XML, but I think that is related to both problems, so it has to be fixed (hopefully) fix my second problem.)


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -