如何应用xmlSerializer兼容属性来返回wcf中的值

时间:2013-12-03 09:15:31

标签: vb.net wcf

如何将xmlserializer兼容属性应用于wcf中的返回值(类)。 我用XmlSerializerFormat修改了我的服务合同,但wcf似乎忽略了这一点。

Edit

这是我需要生成的示例xml

    <account accAlias="0001000260920133" currency="USD">
        <availableBalance>380,072.00</availableBalance>
        <currentBalance>380,072.00</currentBalance>
    </account>

这就是我在WCF中实现它的方式

    Public Class account
        <XmlAttribute()> _
        Public accAlias As String
        <XmlAttribute()> _
        Public currency As String
        Public currentBalance As String
        Public availableBalance As String
    End Class 

然而,我得到的结果就是这个

    <account>
        <accAlias>0001000260920133</accAlias>
        <availableBalance>380,072.00</availableBalance>
        <currency>USD</currency>
        <currentBalance>380,072.00</currentBalance>
    </account>

1 个答案:

答案 0 :(得分:0)

好的,怎么样:

Public Class account
    <XmlAttribute("accAlias")>
    Public accAlias As String
    <XmlAttribute("currency")>
    Public currency As String
    <XmlElement("currentBalance")>
    Public currentBalance As String
    <XmlElement("availableBalance")>
    Public availableBalance As String
End Class