C# Escaping XmlType Name with special char within XmlType() Attribute

▼魔方 西西 提交于 2019-12-12 04:32:37

问题


i need to implement and SOAP Service without using the WSDL (because its broken and will not be fixed). Now im stuck at a point where i need to set type attributes for some classes (base classes and derived one)

normaly ill decorate my DTOs like this:

BaseClass:

[XmlInclude(typeof(Person))]
[XmlType("Partner", Namespace = "http://....")]
public abstract class Partner 
{...}

and the DerivedOne:

 [XmlType("Person")]
public class Person : Partner
{...}

the result looks like this:
<tar:Partner xsi:type="Person">

but now the API Document tells me to create a request like:

<tar:Partner xsi:type="par:CT_Person">

(tested in Fiddler and works) How is it possible to create a typeName set with a NameSpace Prefix (par) or set the name like:

[XmlType("par:CT_Person")]?

deactivate(override) the escaping functionallity is no option for me.

thanks in advance.


回答1:


after testing the whole day and trying around... right after writing my question i got the answer by my self.

when i set the namespace in my baseclass i can set a namespace in my derived one with a different URL. than it works...

hope this post will help someone else facing the problem :)



来源:https://stackoverflow.com/questions/41144363/c-sharp-escaping-xmltype-name-with-special-char-within-xmltype-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!