locked
Creating the xml document dynamically RRS feed

  • Question

  • User136609187 posted

    I am trying the create the below xml structure through code using xml document 

    <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <wsse:UsernameToken wsu:Id="UsernameTokenSYS-20167">
        <wsse:Username>Test</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">INjMj38s6P64XdT1Mq+DPw4Q=</wsse:Password>
       </wsse:UsernameToken>
    </wsse:Security>

    but facing some issues while creating
    this node <wsse:UsernameToken wsu:Id="UsernameTokenSYS-20167"> not able to add "wsu:Id="UsernameTokenSYS-20167"

    and <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">ZCvINjMj38s6P64XdT1Mq+DPw4Q=</wsse:Password>

    and to also to append the "soapenv:mustUnderstand="1" to the root Security Node.

    This is the code which i tried...

    XmlDocument doc = new XmlDocument();
    XmlElement root = doc.CreateElement("wsse:Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
    root.SetAttribute("xmlns:wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
    XmlElement id = doc.CreateElement("wsse", "UsernameToken");
    id.SetAttribute("wsu:Id", "UsernameTokenSYS-20167");

    Please could you help me out here

    Thursday, July 10, 2014 7:56 AM

All replies

  • User521424079 posted

    Hi,

    Do you have got any error message?

    Friday, July 11, 2014 4:12 AM
  • User136609187 posted

    Hi,

    It was not giving any error message but not creating the xml in specified format. I sorted this out using string builder and xmldocument.

    Thanks,

    Friday, July 11, 2014 4:43 AM