Skip to main content

org.apache.cxf.annotations.Policy org.apache.cxf.annotations.Policies (since 2.3)

Used to attach WS-Policy fragments to a service or operation. The Policy supports the attributes:

uri

REQUIRED the location of the file containing the Policy definition

includeInWSDL

Whether to include the policy in the generated WSDL when generating a wsdl. Default it true

placement

Specify where to place the policy

faultClass

if placement is a FAULT, this specifies which fault the policy would apply to

Information noteNote: When using a custom Spring configuration, you'll need to import META-INF/cxf/cxf-extension-policy.xml
@Policies({
   @Policy(uri = "annotationpols/TestInterfacePolicy.xml"),
   @Policy(uri = "annotationpols/TestImplPolicy.xml",
      placement = Policy.Placement.SERVICE_PORT),
   @Policy(uri = "annotationpols/TestPortTypePolicy.xml", 
      placement = Policy.Placement.PORT_TYPE)
})
@WebService
public static interface TestInterface {
   @Policies({
       @Policy(uri = "annotationpols/TestOperationPolicy.xml"),
       @Policy(uri = "annotationpols/TestOperationInputPolicy.xml", 
          placement = Policy.Placement.BINDING_OPERATION_INPUT),
       @Policy(uri = "annotationpols/TestOperationOutputPolicy.xml", 
          placement = Policy.Placement.BINDING_OPERATION_OUTPUT),
       @Policy(uri = "annotationpols/TestOperationPTPolicy.xml", 
          placement = Policy.Placement.PORT_TYPE_OPERATION),
       @Policy(uri = "annotationpols/TestOperationPTInputPolicy.xml", 
          placement = Policy.Placement.PORT_TYPE_OPERATION_INPUT),
       @Policy(uri = "annotationpols/TestOperationPTOutputPolicy.xml", 
          placement = Policy.Placement.PORT_TYPE_OPERATION_OUTPUT)
   })
   int echoInt(int i);
}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!