Как добавить новый объект класса в массив XmlNode? - PullRequest
0 голосов
/ 29 января 2020

Основной вопрос - как добавить новый объект класса (указанный подключенной службой) в массив XmlNode, используя c#?

Я генерировал сообщение soap, добавляя новые объекты / класс в фрейм сообщения , по заранее заданным значениям.

Soap генерация и проблемы:

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
                }
            };

И soap выглядит, с отмеченными проблемами:

<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>

Так как же преобразовать service.InclusiveNamespaces class в xmlNode?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...