Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Chapter 5. The WS-Policy Framework
Abstract
This chapter provides an introduction to the basic concepts of the WS-Policy framework, defining policy subjects and policy assertions, and explaining how policy assertions can be combined to make policy expressions.
5.1. Introduction to WS-Policy Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The WS-Policy specification provides a general framework for applying policies that modify the semantics of connections and communications at runtime in a Web services application. Apache CXF security uses the WS-Policy framework to configure message protection and authentication requirements.
Policies and policy references Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The simplest way to specify a policy is to embed it directly where you want to apply it. For example, to associate a policy with a specific port in the WSDL contract, you can specify it as follows:
An alternative way to specify a policy is to insert a policy reference element,
wsp:PolicyReference
, at the point where you want to apply the policy and then insert the policy element, wsp:Policy
, at some other point in the XML file. For example, to associate a policy with a specific port using a policy reference, you could use a configuration like the following:
Where the policy reference,
wsp:PolicyReference
, locates the referenced policy using the ID, PolicyID (note the addition of the #
prefix character in the URI
attribute). The policy itself, wsp:Policy
, must be identified by adding the attribute, wsu:Id="PolicyID"
.
Policy subjects Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The entities with which policies are associated are called policy subjects. For example, you can associate a policy with an endpoint, in which case the endpoint is the policy subject. It is possible to associate multiple policies with any given policy subject. The WS-Policy framework supports the following kinds of policy subject:
Service policy subject Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To associate a policy with a service, insert either a
<wsp:Policy>
element or a <wsp:PolicyReference>
element as a sub-element of the following WSDL 1.1 element:
wsdl:service
—apply the policy to all of the ports (endpoints) offered by this service.
Endpoint policy subject Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To associate a policy with an endpoint, insert either a
<wsp:Policy>
element or a <wsp:PolicyReference>
element as a sub-element of any of the following WSDL 1.1 elements:
wsdl:portType
—apply the policy to all of the ports (endpoints) that use this port type.wsdl:binding
—apply the policy to all of the ports that use this binding.wsdl:port
—apply the policy to this endpoint only.
For example, you can associate a policy with an endpoint binding as follows (using a policy reference):
Operation policy subject Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To associate a policy with an operation, insert either a
<wsp:Policy>
element or a <wsp:PolicyReference>
element as a sub-element of any of the following WSDL 1.1 elements:
wsdl:portType/wsdl:operation
wsdl:binding/wsdl:operation
For example, you can associate a policy with an operation in a binding as follows (using a policy reference):
Message policy subject Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To associate a policy with a message, insert either a
<wsp:Policy>
element or a <wsp:PolicyReference>
element as a sub-element of any of the following WSDL 1.1 elements:
wsdl:message
wsdl:portType/wsdl:operation/wsdl:input
wsdl:portType/wsdl:operation/wsdl:output
wsdl:portType/wsdl:operation/wsdl:fault
wsdl:binding/wsdl:operation/wsdl:input
wsdl:binding/wsdl:operation/wsdl:output
wsdl:binding/wsdl:operation/wsdl:fault
For example, you can associate a policy with a message in a binding as follows (using a policy reference):