Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to generate username token id in the request header of a soap Request. I am using with c#.
I tried to generate Username token as below:
UsernameToken userToken = new UsernameToken(Username, Password, PasswordOption.SendHashed);
I am getting username token Id output as
But In many sample soap request usernametoken id value seen as UsernameToken-DFDA939C85F8B13ADA154211040258026.
Please update which is the proper way to pass username token id in a soap request header.

What I have tried:

Core Code is as below:
             UsernameToken userToken = new UsernameToken(Username, Password, PasswordOption.SendHashed);

                             string oRequest = @"<soapenv:Envelope xmlns:soapenv="""" xmlns:enq="""">
                             <soapenv:Header><wsse:Security xmlns:wsse="""" xmlns:wsu="""">
<wsse:UsernameToken wsu:Id="+userToken .Id+"><wsse:Username>" + Username + @"</wsse:Username><wsse:Password Type="""">" + strPssDigest + @"</wsse:Password><wsse:Nonce EncodingType="""">" + strNonce + @"</wsse:Nonce><wsu:Created>" + strCreatedDate + @"</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
                             <soapenv:Body>" + Body + @"</soapenv:Body>
Updated 6-Apr-22 23:20pm
Richard Deeming 7-Apr-22 5:24am    
Deleting and reposting your question will not change the answers you get.
Member 7513082 7-Apr-22 6:55am    
to get a response i just reposted the need much more precisely and shortly. please respond to the same if any one is clear on this
Chris Copeland 7-Apr-22 9:27am    
Is the request rejected if the username token doesn't begin with UsernameToken- or are you just comparing the token you're generating with others? If it works then presumably it's the correct way to do things. You'd need to consult the documentation for both the SOAP API you're using, and the C# library that you're also using to make the API calls.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900