我可以使用以下MessageContracts作为请求:
<MessageContract(WrapperName:="get")> _
Public Class GetRequest
Inherits BaseAuthenticatedRequest
Protected _typeName As cEnum.eType
Protected _id As Integer
<MessageBodyMember()> _
Public Property TypeName() As cEnum.eType
...
<MessageBodyMember()> _
Public Property Id() As Integer
...
End Class
<MessageContract(WrapperName:="getLimited")> _
Public Class GetLimitedRequest
Inherits GetRequest
Protected _propertyList As List(Of String)
<MessageBodyMember(Namespace:=Api2Information.Namespace)> _
Public Property PropertyList() As List(Of String)
...
End Class但在SoapUI中测试时,getLimited请求正文被创建为:
<v2:getLimited>
<!--Optional:-->
<v2:Id>?</v2:Id>
<!--Optional:-->
<v2:PropertyList>
<!--Zero or more repetitions:-->
<arr:string>?</arr:string>
</v2:PropertyList>
<!--Optional:-->
<v2:TypeName>?</v2:TypeName>
</v2:getLimited>其中v2 = Api2Information.Namespace。我真正想要的是将PropertyList中包含的字符串命名为v2,而不是arr。有没有办法让我做到这一点?我正在将一个ASMX服务转换为使用WCF,我们有一些应用程序,我们无法承担重新编译和重新分发的费用。
感谢您的帮助!
发布于 2010-10-30 00:01:00
我找到了我要找的东西。使用自定义集合类型,如:
<CollectionDataContract(Namespace:=Api2Information.Namespace)> _
Public Class PropertyList : Inherits List(Of String)
End Class并在我的合同中替换它的出现,比如:
<MessageContract(WrapperName:="getLimited")> _
Public Class GetLimitedRequest
Inherits GetRequest
Protected _propertyList As PropertyList
<MessageBodyMember(Namespace:=Api2Information.Namespace)> _
Public Property PropertyList() As PropertyList
...
End Class生成输出:
<v2:getLimited>
<!--Optional:-->
<v2:Id>?</v2:Id>
<!--Optional:-->
<v2:PropertyList>
<!--Zero or more repetitions:-->
<v2:string>?</v2:string>
</v2:PropertyList>
<!--Optional:-->
<v2:TypeName>?</v2:TypeName>
</v2:getLimited>https://stackoverflow.com/questions/4052289
复制相似问题