C# 如何向XmlNode数组添加新的类对象?

C# 如何向XmlNode数组添加新的类对象?,c#,xml,web-services,soap,C#,Xml,Web Services,Soap,主要问题是-如何使用c#将新的类对象(由连接的服务指定)添加到XmlNode数组中 我通过在消息框架中添加新的对象/类,通过预定义的值来生成soap消息 Soap生成和问题: 而soap看起来像是有明显问题的: 一些东西 公民 auth.tsl.identity.card 授权银行 授权签名提供者 auth.login.pass 身份证 白鹳 auth.tsl.identity.card 个人代码 公司代码 名字 姓氏 公司名称 https://noneedtoknow.com {如何添加:

主要问题是-如何使用c#将新的类对象(由连接的服务指定)添加到XmlNode数组中

我通过在消息框架中添加新的对象/类,通过预定义的值来生成soap消息

Soap生成和问题:

而soap看起来像是有明显问题的:


一些东西
公民
auth.tsl.identity.card
授权银行
授权签名提供者
auth.login.pass
身份证
白鹳
auth.tsl.identity.card
个人代码
公司代码
名字
姓氏
公司名称
https://noneedtoknow.com
{如何添加:
}
{某些签名}

因此,如何将
service.InclusiveNamespaces类
转换为
xmlNode

并不完全确定您在这里要做什么,但是如果您需要将c#POCO直接序列化为
xmlNode
(或者更具体地说,是
xmlement
)请参阅
XmlNodeExtensions.asxmlement(此T o,…)
从至和也到。请参阅以下帖子:
authenticationRequest request = new authenticationRequest
            {
                pid = PID,
                authenticationProvider = new[]
                {
                    authenticationProvider.authtslidentitycard,
                    authenticationProvider.authltbank,
                    authenticationProvider.authsignatureProvider,
                    authenticationProvider.authloginpass,
                    authenticationProvider.authltgovernmentemployeecard,
                    authenticationProvider.authstork,
                    authenticationProvider.authtslidentitycard
                },
                authenticationAttribute = new[]
                {
                    authenticationAttribute.ltpersonalcode,
                    authenticationAttribute.ltcompanycode,
                },
                postbackUrl = RETURN_URL,
                customData = customData,
                Signature = new SignatureType
                {
                    SignatureValue = new SignatureValueType
                    {
                        Value = sigInBytes,
                    },
                    KeyInfo = new KeyInfoType
                    {
                        Items = new object[]
                        {
                            !!TODO!!
                        }
                    },
                    SignedInfo = new SignedInfoType
                    {
                        CanonicalizationMethod = new CanonicalizationMethodType
                        {
                            Algorithm = "http://www.w3.org/2001/10/xml-exc-c14n#",
                            Any = new XmlNode[]
                            {
                             !!TODO!!
                             At this point error occurs:
                             InclusiveNamespaces{
                                    PrefixList = "authentification"
                                }
                            },

                        },
                        SignatureMethod = new SignatureMethodType
                        {
                            Algorithm = "http://www.w3.org/2001/10/xml-exc-c14n#",
                            Any = new XmlNode[]
                            {

                            }
                        }
                    }
                },
                userInformation = new[]
                {
                    userInformation.firstName,
                    userInformation.lastName,
                    userInformation.companyName
                }
            };
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <authenticationRequest xmlns="http://serviceUrl/.../..">
      <pid>SomeStuff</pid>
      <serviceTarget>citizen</serviceTarget>
      <authenticationProvider>auth.tsl.identity.card</authenticationProvider>
      <authenticationProvider>auth.bank</authenticationProvider>
      <authenticationProvider>auth.signatureProvider</authenticationProvider>
      <authenticationProvider>auth.login.pass</authenticationProvider>
      <authenticationProvider>auth.government.employee.card</authenticationProvider>
      <authenticationProvider>auth.stork</authenticationProvider>
      <authenticationProvider>auth.tsl.identity.card</authenticationProvider>
      <authenticationAttribute>personal-code</authenticationAttribute>
      <authenticationAttribute>company-code</authenticationAttribute>
      <userInformation>firstName</userInformation>
      <userInformation>lastName</userInformation>
      <userInformation>companyName</userInformation>
      <postbackUrl>https://noneedtoknow.com</postbackUrl>
      <customData />
      <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
        <SignedInfo>
          <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
          {HOW TO ADD : 
          <InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" 
                PrefixList="authentication" />
          }
          </CanonicalizationMethod>
          <SignatureMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
        </SignedInfo>
        <SignatureValue>{SOME SIGNATURE}</SignatureValue>
        <KeyInfo />
      </Signature>
    </authenticationRequest>
  </s:Body>
</s:Envelope>