Author: buildbot Date: Thu Apr 12 11:57:19 2018 New Revision: 1028304 Log: Production update by buildbot for cxf
Modified: websites/production/cxf/content/cache/docs.pageCache websites/production/cxf/content/docs/how-to-define-policies.html Modified: websites/production/cxf/content/cache/docs.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/cxf/content/docs/how-to-define-policies.html ============================================================================== --- websites/production/cxf/content/docs/how-to-define-policies.html (original) +++ websites/production/cxf/content/docs/how-to-define-policies.html Thu Apr 12 11:57:19 2018 @@ -32,8 +32,8 @@ <link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shThemeCXF.css"> <script src='/resources/highlighter/scripts/shCore.js'></script> -<script src='/resources/highlighter/scripts/shBrushXml.js'></script> <script src='/resources/highlighter/scripts/shBrushJava.js'></script> +<script src='/resources/highlighter/scripts/shBrushXml.js'></script> <script> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -117,38 +117,23 @@ Apache CXF -- How to Define Policies <td height="100%"> <!-- Content --> <div class="wiki-content"> -<div id="ConfluenceContent"><p>There are basically 3 main possibilities to define WS-Policy in CXF projects:</p> -<ol><li>WSDL Policy attachment</li><li>Spring configuration</li><li>Dynamically via message context property</li></ol> - - -<p>Let look into them in details. </p> - -<h4 id="HowtoDefinePolicies-WSDLPolicyattachment">WSDL Policy attachment</h4> -<p>WS-Policies can be attached and referenced in WSDL elements. <a shape="rect" class="external-link" href="http://www.w3.org/TR/ws-policy-attach/" rel="nofollow">Web Services Policy 1.5 - Attachment </a> standard describes all possible alternatives. WS-Policies can be placed inside WSDL itself or referenced as external documents. CXF will automatically recognize, read and use policies defined or referenced in WSDL. Sample of attached policy is shown below:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> -<wsdl:definitions name="HelloWorld" targetNamespace="http://apache.org/hello_world_soap_http" -… -<wsdl:service name="SOAPService"> - <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort"> - <soap:address location="http://localhost:9000/SoapContext/SoapPort"/> - <wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy"> - <wsam:Addressing xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"> - <wsp:Policy/> - </wsam:Addressing> - </wsp:Policy> - </wsdl:port> -</wsdl:service> +<div id="ConfluenceContent"><p>There are basically 4 main possibilities to define WS-Policy in CXF projects:</p><ol><li>WSDL Policy attachment</li><li>Spring configuration</li><li>In code using WSPolicyFeature</li><li>Dynamically via message context property</li></ol><p>Let look into them in detail.</p><h4 id="HowtoDefinePolicies-WSDLPolicyattachment">WSDL Policy attachment</h4><p>WS-Policies can be attached and referenced in WSDL elements. <a shape="rect" class="external-link" href="http://www.w3.org/TR/ws-policy-attach/" rel="nofollow">Web Services Policy 1.5 - Attachment </a> standard describes all possible alternatives. WS-Policies can be placed inside the WSDL itself or referenced as external documents. CXF will automatically recognize, read and use policies defined or referenced in WSDL. A sample of an attached policy is shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><wsdl:definitions name="HelloWorld" targetNamespace="http://apache.org/hello_world_soap_http" + … + <wsdl:service name="SOAPService"> + <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort"> + <soap:address location="http://localhost:9000/SoapContext/SoapPort"/> + <wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy"> + <wsam:Addressing xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"> + <wsp:Policy/> + </wsam:Addressing> + </wsp:Policy> + </wsdl:port> + </wsdl:service> </wsdl:definitions> </pre> -</div></div> - -<h4 id="HowtoDefinePolicies-Springconfiguration">Spring configuration</h4> -<p>It is possible to define policies directly in Spring configuration of client and service as jaxws feature. CXF will recognize and use configured WS-Policies:<br clear="none"> -Client:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> -<beans xmlns="http://www.springframework.org/schema/beans" +</div></div><h4 id="HowtoDefinePolicies-Springconfiguration">Spring configuration</h4><p>It is possible to define policies directly in the Spring configuration of the client and service as a jaxws feature. CXF will recognize and use configured WS-Policies:<br clear="none"> Client:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xmlns:p="http://cxf.apache.org/policy" @@ -158,6 +143,7 @@ http://cxf.apache.org/core http://cxf.ap http://cxf.apache.org/policy http://cxf.apache.org/schemas/policy.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> + <jaxws:client id="CRMServiceClient" name="{http://services.talend.org/CRMService}CRMServiceProvider" xmlns:serviceNamespace="http://services.talend.org/CRMService" serviceClass="org.talend.services.crmservice.CRMService" @@ -172,12 +158,8 @@ http://cxf.apache.org/jaxws http://cxf.a </jaxws:client> </beans> </pre> -</div></div> - -<p>Service:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> -<beans xmlns="http://www.springframework.org/schema/beans" +</div></div><p>Service:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xmlns:p="http://cxf.apache.org/policy" @@ -187,7 +169,7 @@ http://cxf.apache.org/core http://cxf.ap http://cxf.apache.org/policy http://cxf.apache.org/schemas/policy.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> - <jaxws:endpoint id="CRMService" +  <jaxws:endpoint id="CRMService" xmlns:serviceNamespace="http://services.talend.org/CRMService" serviceName="serviceNamespace:CRMServiceProvider" endpointName="serviceNamespace:CRMServicePort" @@ -201,13 +183,19 @@ http://cxf.apache.org/jaxws http://cxf.a </jaxws:endpoint> </beans> </pre> -</div></div> - -<h4 id="HowtoDefinePolicies-Dynamicallyviamessageproperty">Dynamically via message property</h4> -<p>Sometimes policies cannot be configured statically, because they are obtained or calculated dynamically for concrete message (for example using Policy Server or Service Registry). For such cases CXF provide a possibility to load policy dynamically and set it into the message context property. It can be done for example in custom interceptor that fulfils the following:</p> -<ol><li>Get policy from external location and build it for current message.</li><li>Parse WS-Policy XML using Neethi library.</li><li>Store result Policy object into <em>PolicyConstants.POLICY_OVERRIDE</em> message content property.<br clear="none"> -Important is that this custom policy interceptor is called before CXF <em>PolicyInInterceptor</em> or <em>PolicyOutInterceptor</em>. Than CXF will automatically recognize Policy stored into this property and use it with highest priority.</li></ol> -</div> +</div></div><h4 id="HowtoDefinePolicies-IncodeviaWSPolicyFeature">In code via WSPolicyFeature</h4><p>Instead of loading the policies via Spring as detailed in the previous section, we can load the policies via code using the WSPolicyFeature, and then set it on a ClientFactoryBean, ServerFactoryBean or ClientProxyFactoryBean instance, for example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>WSPolicyFeature</b></div><div class="codeContent panelContent pdl"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">import org.apache.cxf.staxutils.StaxUtils; +import org.apache.cxf.ws.policy.WSPolicyFeature; +... + +WSPolicyFeature policyFeature = new WSPolicyFeature(); +Element policyElement = + StaxUtils.read(getClass().getResourceAsStream("saml.policy")).getDocumentElement(); +policyFeature.setPolicyElements(Collections.singletonList(policyElement)); + +JaxWsProxyFactoryBean clientFactoryBean = new JaxWsProxyFactoryBean(); +clientFactoryBean.setFeatures(Collections.singletonList(policyFeature));</pre> +</div></div><p> </p><h4 id="HowtoDefinePolicies-Dynamicallyviamessageproperty">Dynamically via message property</h4><p>Sometimes policies cannot be configured statically, because they are obtained or calculated dynamically for the concrete message (for example using Policy Server or Service Registry). For such cases CXF provides a possibility to load the policy dynamically and set it into the message context property. It can be done for example in a custom interceptor that fulfills the following:</p><ol><li>Get policy from external location and build it for current message.</li><li>Parse WS-Policy XML using Neethi library.</li><li>Store result Policy object into <em>PolicyConstants.POLICY_OVERRIDE</em> message content property.<br clear="none"> It is important that this custom policy interceptor is called before CXF <em>PolicyInInterceptor</em> or <em>PolicyOutInterceptor</em>. Then CXF will automatically recognize Policy stored into this property and use it with the highest pr iority.</li></ol></div> </div> <!-- Content --> </td>