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

标签 c# wcf soap

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

如何指定 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/

相关文章:

c# - 用于在 C# 中解析 SQL 查询的正则表达式

c# - 数据契约WCF放在哪里?可以放入数据层吗?

wcf - 在 WCF RequestInterceptor 中访问 HttpContext

java - Apache CXF java.lang.StackOverflowError

soap - 具有大消息的 JAX-WS SoapHandler : OutOfMemoryError

javascript - 从 C# 获取 JavaScript 中相同的 double 值

c# - 使用存储过程和 ADO.NET 更新数据库

c# - 将 8bpp 图像转换为 24bpp 并保留颜色

wcf - 你将只有自治服务

javascript - 使用 npm 请求向 SOAP api 发送帖子