Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is probably a smarter way, but you can add the headers manually like this:</p> <pre><code>var client = new IdentityProofingService.IdentityProofingWSClient(); using (new OperationContextScope(client.InnerChannel)) { OperationContext.Current.OutgoingMessageHeaders.Add( new SecurityHeader("UsernameToken-49", "12345/userID", "password123")); client.invokeIdentityService(new IdentityProofingRequest()); } </code></pre> <p>Here, <code>SecurityHeader</code> is a custom implemented class, which needs a few other classes since I chose to use attributes to configure the XML serialization:</p> <pre><code>public class SecurityHeader : MessageHeader { private readonly UsernameToken _usernameToken; public SecurityHeader(string id, string username, string password) { _usernameToken = new UsernameToken(id, username, password); } public override string Name { get { return "Security"; } } public override string Namespace { get { return "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; } } protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion) { XmlSerializer serializer = new XmlSerializer(typeof(UsernameToken)); serializer.Serialize(writer, _usernameToken); } } [XmlRoot(Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")] public class UsernameToken { public UsernameToken() { } public UsernameToken(string id, string username, string password) { Id = id; Username = username; Password = new Password() {Value = password}; } [XmlAttribute(Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd")] public string Id { get; set; } [XmlElement] public string Username { get; set; } [XmlElement] public Password Password { get; set; } } public class Password { public Password() { Type = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"; } [XmlAttribute] public string Type { get; set; } [XmlText] public string Value { get; set; } } </code></pre> <p>I have not added the <code>Nonce</code> bit to the <code>UsernameToken</code> XML, but it is very similar to the <code>Password</code> one. The <code>Created</code> element also needs to be added still, but it's a simple <code>[XmlElement]</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload