C# 在 XmlType() 属性中使用特殊字符转义 XmlType 名称 [英] C# Escaping XmlType Name with special char within XmlType() Attribute

查看:32
本文介绍了C# 在 XmlType() 属性中使用特殊字符转义 XmlType 名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在不使用 WSDL 的情况下实现 SOAP 服务(因为它已损坏并且不会被修复).现在我陷入了需要为某些类(基类和派生类)设置类型属性的点

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)

通常会像这样装饰我的 DTO:

normaly ill decorate my DTOs like this:

基类:

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

和 DerivedOne:

and the DerivedOne:

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

结果如下:

但现在 API 文档告诉我创建一个请求,如:

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

(在 Fiddler 中测试并有效)如何创建带有 NameSpace Prefix (par) 的 typeName 集或将名称设置为:

(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.

提前致谢.

推荐答案

经过一整天的测试和尝试......写完我的问题后,我自己得到了答案.

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

当我在基类中设置命名空间时,我可以在派生的命名空间中使用不同的 URL 设置命名空间.比它有效...

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 :)

这篇关于C# 在 XmlType() 属性中使用特殊字符转义 XmlType 名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆