JBoss.org Community Documentation
Using JBoss proprietary annotation you only have to provide the policy xml, leaving wsdl generation to the JBossWS deployer.
There are two annotations to use, the first one (@PolicyAttachment) containing an array of the second one (@Policy): this lets you have many policies attached to a class or method. In future domain policy implementations might ship domain annotations extending the @Policy annotation to provide needed metadata directly as annotation parameters. The current @Policy annotation takes a reference to a xml file containing a generic policy description written respecting ws-policy specification rules.
/** @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface PolicyAttachment { Policy[] value(); } ... @Retention(RetentionPolicy.RUNTIME) public @interface Policy { public String policyFileLocation(); public PolicyScopeLevel scope(); }
And here you have the previous section example re-implemented using annotations and xml policy file:
@WebService(name = "Hello", targetNamespace = "http://org.jboss.ws/samples/wssecurityAnnotatedpolicy") @PolicyAttachment({@Policy( policyFileLocation="WEB-INF/Policy.xml", scope = PolicyScopeLevel.WSDL_PORT ) }) @SOAPBinding(style = SOAPBinding.Style.RPC) public class HelloJavaBean { private Logger log = Logger.getLogger(HelloJavaBean.class); @WebMethod public UserType echoUserType(@WebParam(name = "user") UserType in0) { log.info(in0); return in0; } } <?xml version="1.0" encoding="UTF-8"?> ... <wsp:Policy wsu:Id="X509EndpointPolicy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsp:ExactlyOne> <wsp:All> <sp:jboss-ws-security xmlns:sp="http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd"> <sp:key-store-file>WEB-INF/wsse.keystore</sp:key-store-file> <sp:key-store-password>jbossws</sp:key-store-password> <sp:trust-store-file>WEB-INF/wsse.truststore</sp:trust-store-file> <sp:trust-store-password>jbossws</sp:trust-store-password> <sp:config> <sp:encrypt type="x509v3" alias="wsse"/> <sp:requires> <sp:encryption/> </sp:requires> </sp:config> </sp:jboss-ws-security> </wsp:All> </wsp:ExactlyOne> </wsp:Policy>