Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

CXF's WS-Policy Framework is described in more detail in the WS-Policy Framework User's Guide . Like manu pther many other features in CXF, the implementation is interceptor based, and thus the computation of the effective policy for a specific message (as well as the verification that one of the alternatives of that effective policy is supported happen ) happens in interceptors. As there are quite a number of interceptors involved, these are not normally on the interceptor chains, i.e. the WS-Policy Framework is disabled. To enable it, use any of the following options:

...

The policies feature element is defined in namespace http://cxf.apache.org/policy-configImage Removed. It supports two attributesone attribute:

Name

Value

ignoreUnknownAssertions

Indicates an exception should be thrown when encountering assertions for which no AssertionBuilders are registered (default: true). When set to false, a warning will be logged instead. namespace

The

...

).

The element also support the the following child elements:

...

For example, to apply this feature to a the bus and prevent exceptions being thrown when encountering unknown assertions:

Code Block
xml
xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:cxf="http://cxf.apache.org/core"
       xmlns:p="http://cxf.apache.org/policy-config"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/policy-config http://cxf.apache.org/schemas/policy-config.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <cxf:bus>
        <cxf:features>
            <p:policies ignoreUnknownAssertions="true"/>
        </cxf:features>
    </cxf:bus>
</beans>

...

The policy engine is the central instance of the WS-Policy framework implementation. You can enable and configure it directly, using the <engine> element in the http://cxf.apache.org/policy-configImage Removed namespace. This element supports the same attributes and child elements as the <policies< element> <policies> element above, except:

  • It supports the additional attribute 'enabled' of type boolean (default: false) to determine if the engine, and hence the policy framework, is enabled.
  • It ignores Policy and PolicyReference child elements.

Following The following configuration achieves the same as in the example above:

Code Block
xml
xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:cxf="http://cxf.apache.org/core"
       xmlns:p="http://cxf.apache.org/policy-config"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/policy-config http://cxf.apache.org/schemas/policy-config.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <p:engine enabled="true" ignoreUnknownAssertions="true"/>
</beans>      

Note: Starting with CXF 2.2, the Policy Engine defaults to enabled=true and ignoreUnknownAssertions=true. Thus, the above configuration is no-longer needed as that is the default.

Specifying the Location of External Attachments

To specify the location of an external attachment that the policy framework should take into consideration when aggregating the policies applying to a specific message, you can use the <externalAttachment> element in the same namespace. It supports the following attributes:

Name

Value

location

Location of the external attachment document. This takes the form of a Spring Resource type property, e.g. 'classpath:etc/policies.xml' or 'file:/x1/resources/

polcies

policies.xml'.

Example:

Code Block
xml
xml

    <p:externalAttachment location="classpath:org/apache/cxf/systest/ws/policy/addr-external.xml"/>
</bean>

You can have any number of <externalAttachment> elements in your configuration file.