Skip to main content

Adding Security Header Elements

Adding Security Header Elements

To add a security element to the WS-Security header element, you use the following general procedure in your web client or web service:

  1. Create an instance of the applicable class or classes. To do so, you use a method named Create() or CreateX509(), depending on the class. The instance represents one of the WS-Security header elements such as <Username> or <EncryptedKey>.

  2. Add each instance to the WS-Security header element by updating the SecurityOut property of your web client or web service. To do so, call the AddSecurityElement() method.

  3. Send the SOAP message. The WS-Security header is included in the message and contains the elements that you added to it.

  4. For subsequent outbound messages:

    • For a web client, the SecurityOut property is left unchanged, so that subsequent outbound messages from this instance include the security header you added. If this is undesirable, set the SecurityOut property to null.

    • For a web service, the SecurityOut property is automatically set to null after the first outbound SOAP message.

FeedbackOpens in a new tab