gpt4 book ai didi

c# - 在 SOAP 信封中创建新字典

转载 作者:太空狗 更新时间:2023-10-29 20:39:23 26 4
gpt4 key购买 nike

非常基本的问题,但我似乎无法在任何地方找到答案。

如何指定 Dictionary<string, string> 的新实例?在 SOAP ?基本上我有这个信封(为了便于阅读省略了信封顶级标签):

<soapenv:Body>
<tem:LogInWithCredentials>
<tem:Request>
<ttf1:Password>password</ttf1:Password>
<ttf1:UserName>username</ttf1:UserName>
<ttf1:RequestInfo></ttf1:RequestInfo>
</tem:Request>
</tem:LogInWithCredentials>
</soapenv:Body>

RequestInfo是有问题的属性,但它始终是 null .我假设只有信封中存在的属性会被反序列化为一个空的 Dictionary<string, string>。 , 然而事实并非如此。

最佳答案

正如@flem 所说,DataContractSerializer 可能提供回答这个问题所需的线索。序列化一个空字典会得到以下 XML。在您的 RequestInfo 元素中尝试一下,看看它是否有效(我自己没有测试过)。

<ArrayOfKeyValueOfstringstring 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

关于c# - 在 SOAP 信封中创建新字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22811318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com