How to: Declare a Policy

The following procedure details how to declare a policy within a policy file.

To declare a policy

  1. Add a <policy> childelement to the <policies> element.

  2. Set the Id attribute of the <policy> element to the name of the policy.

    The Id attribute must conform to the ID attribute as defined in the XML 1.0 recommendation. Specifically, the name begins with a letter or underscore and continues with name characters (letters, digits, and other characters) and must be unique to the policy file.

  3. Add one or more requirements to the policy assertion.

Example

The following code example is a policy file containing a declaration for the policy that specifies that a message requires a digital signature.

<?xml version="1.0" encoding="utf-8" ?>
<policyDocument xmlns="https://schemas.microsoft.com/wse/2003/06/Policy">
  <mappings>
    <endpoint >
  </mappings>
  <policies xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wssp="https://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsp="https://schemas.xmlsoap.org/ws/2002/12/policy">
    <wsp:Policy wsu:Id="signed-body-x509">
      <Integrity wsp:Usage="wsp:Required"     xmlns="https://schemas.xmlsoap.org/ws/2002/12/secext">
        <wssp:TokenInfo>
          <wssp:SecurityToken>
            <wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3</wssp:TokenType> 
          </wssp:SecurityToken>
        </wssp:TokenInfo>
        <MessageParts xmlns:rp=https://schemas.xmlsoap.org/rp Dialect="https://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body()</MessageParts> 
      </Integrity>
    </wsp:Policy>
  </policies>
</PolicyDocument>

See Also

Tasks

How to: Create a Policy File

Concepts

Policy Overview

Other Resources

Configuring a Web Service's Policy