| <!DOCTYPE html> |
| <!-- |
| | Generated by Apache Maven Doxia Site Renderer 1.7.4 at 2017-07-30 |
| | Rendered using Apache Maven Fluido Skin 1.6 |
| --> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta charset="UTF-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <meta name="Date-Revision-yyyymmdd" content="20170730" /> |
| <meta http-equiv="Content-Language" content="en" /> |
| <title>Apache Axis2 – WS Policy Support in Axis2</title> |
| <link rel="stylesheet" href="../css/apache-maven-fluido-1.6.min.css" /> |
| <link rel="stylesheet" href="../css/site.css" /> |
| <link rel="stylesheet" href="../css/print.css" media="print" /> |
| <script type="text/javascript" src="../js/apache-maven-fluido-1.6.min.js"></script> |
| <meta name="generator" content="HTML Tidy for Windows (vers 14 June 2007), see www.w3.org" /><meta http-equiv="content-type" content="text/html; charset=us-ascii" /><meta name="generator" content="amaya 9.2.1, see http://www.w3.org/Amaya/" /> </head> |
| <body class="topBarDisabled"> |
| <div class="container-fluid"> |
| <div id="banner"> |
| <div class="pull-left"><a href="http://www.apache.org/" id="bannerLeft"><img src="http://www.apache.org/images/asf_logo_wide.png" alt="Apache Axis2"/></a></div> |
| <div class="pull-right"><a href=".././" id="bannerRight"><img src="../images/axis.jpg" /></a></div> |
| <div class="clear"><hr/></div> |
| </div> |
| |
| <div id="breadcrumbs"> |
| <ul class="breadcrumb"> |
| <li id="publishDate">Last Published: 2017-07-30<span class="divider">|</span> |
| </li> |
| <li id="projectVersion">Version: 1.7.6<span class="divider">|</span></li> |
| <li class=""><a href="http://www.apache.org" class="externalLink" title="Apache">Apache</a><span class="divider">/</span></li> |
| <li class=""><a href="../index.html" title="Axis2/Java">Axis2/Java</a><span class="divider">/</span></li> |
| <li class="active ">WS Policy Support in Axis2</li> |
| </ul> |
| </div> |
| <div class="row-fluid"> |
| <div id="leftColumn" class="span2"> |
| <div class="well sidebar-nav"> |
| <ul class="nav nav-list"> |
| <li class="nav-header">Axis2/Java</li> |
| <li><a href="../index.html" title="Home"><span class="none"></span>Home</a> </li> |
| <li><a href="../download.html" title="Downloads"><span class="none"></span>Downloads</a> </li> |
| <li><a href="javascript:void(0)" title="Release Notes"><span class="icon-chevron-down"></span>Release Notes</a> |
| <ul class="nav nav-list"> |
| <li><a href="../release-notes/1.6.1.html" title="1.6.1"><span class="none"></span>1.6.1</a> </li> |
| <li><a href="../release-notes/1.6.2.html" title="1.6.2"><span class="none"></span>1.6.2</a> </li> |
| <li><a href="../release-notes/1.6.3.html" title="1.6.3"><span class="none"></span>1.6.3</a> </li> |
| <li><a href="../release-notes/1.6.4.html" title="1.6.4"><span class="none"></span>1.6.4</a> </li> |
| <li><a href="../release-notes/1.7.0.html" title="1.7.0"><span class="none"></span>1.7.0</a> </li> |
| <li><a href="../release-notes/1.7.1.html" title="1.7.1"><span class="none"></span>1.7.1</a> </li> |
| <li><a href="../release-notes/1.7.2.html" title="1.7.2"><span class="none"></span>1.7.2</a> </li> |
| <li><a href="../release-notes/1.7.3.html" title="1.7.3"><span class="none"></span>1.7.3</a> </li> |
| <li><a href="../release-notes/1.7.4.html" title="1.7.4"><span class="none"></span>1.7.4</a> </li> |
| <li><a href="../release-notes/1.7.5.html" title="1.7.5"><span class="none"></span>1.7.5</a> </li> |
| <li><a href="../release-notes/1.7.6.html" title="1.7.6"><span class="none"></span>1.7.6</a> </li> |
| </ul> |
| </li> |
| <li><a href="../modules/index.html" title="Modules"><span class="none"></span>Modules</a> </li> |
| <li><a href="../tools/index.html" title="Tools"><span class="none"></span>Tools</a> </li> |
| <li class="nav-header">Documentation</li> |
| <li><a href="../docs/toc.html" title="Table of Contents"><span class="none"></span>Table of Contents</a> </li> |
| <li><a href="../docs/installationguide.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li> |
| <li><a href="../docs/quickstartguide.html" title="QuickStart Guide"><span class="none"></span>QuickStart Guide</a> </li> |
| <li><a href="../docs/userguide.html" title="User Guide"><span class="none"></span>User Guide</a> </li> |
| <li><a href="../docs/jaxws-guide.html" title="JAXWS Guide"><span class="none"></span>JAXWS Guide</a> </li> |
| <li><a href="../docs/pojoguide.html" title="POJO Guide"><span class="none"></span>POJO Guide</a> </li> |
| <li><a href="../docs/spring.html" title="Spring Guide"><span class="none"></span>Spring Guide</a> </li> |
| <li><a href="../docs/webadminguide.html" title="Web Administrator's Guide"><span class="none"></span>Web Administrator's Guide</a> </li> |
| <li><a href="../docs/migration.html" title="Migration Guide (from Axis1)"><span class="none"></span>Migration Guide (from Axis1)</a> </li> |
| <li class="nav-header">Resources</li> |
| <li><a href="../faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li> |
| <li><a href="../articles.html" title="Articles"><span class="none"></span>Articles</a> </li> |
| <li><a href="http://wiki.apache.org/ws/FrontPage/Axis2/" class="externalLink" title="Wiki"><span class="none"></span>Wiki</a> </li> |
| <li><a href="../refLib.html" title="Reference Library"><span class="none"></span>Reference Library</a> </li> |
| <li><a href="../apidocs/index.html" title="Online Java Docs"><span class="none"></span>Online Java Docs</a> </li> |
| <li class="nav-header">Get Involved</li> |
| <li><a href="../overview.html" title="Overview"><span class="none"></span>Overview</a> </li> |
| <li><a href="../svn.html" title="Checkout the Source"><span class="none"></span>Checkout the Source</a> </li> |
| <li><a href="../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li> |
| <li><a href="../release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li> |
| <li><a href="../guidelines.html" title="Developer Guidelines"><span class="none"></span>Developer Guidelines</a> </li> |
| <li><a href="../siteHowTo.html" title="Build the Site"><span class="none"></span>Build the Site</a> </li> |
| <li class="nav-header">Project Information</li> |
| <li><a href="../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li> |
| <li><a href="../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li> |
| <li><a href="http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/" class="externalLink" title="Source Code"><span class="none"></span>Source Code</a> </li> |
| <li><a href="../thanks.html" title="Acknowledgements"><span class="none"></span>Acknowledgements</a> </li> |
| <li class="nav-header">Apache</li> |
| <li><a href="http://www.apache.org/licenses/LICENSE-2.0.html" class="externalLink" title="License"><span class="none"></span>License</a> </li> |
| <li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li> |
| <li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li> |
| <li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li> |
| </ul> |
| <hr /> |
| <div id="poweredBy"> |
| <div class="clear"></div> |
| <div class="clear"></div> |
| <div class="clear"></div> |
| <div class="clear"></div> |
| <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../images/logos/maven-feather.png" /></a> |
| </div> |
| </div> |
| </div> |
| <div id="bodyColumn" class="span10" > |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| |
| |
| <h1 align="center">Web Services Policy Support In Apache Axis2</h1> |
| |
| <p>This document gives you an introduction to the role of Web |
| services policy in Apache Axis2.</p> |
| |
| <p>Send your feedback to: <a class="externalLink" href="mailto:java-dev@axis.apache.org?subject=[Axis2]">java-dev@axis.apache.org</a>. |
| (Subscription details are available on the <a href="../mail-lists.html">Axis2 site</a>.) |
| Kindly prefix every email subject with [Axis2].</p> |
| |
| <div class="section"> |
| <h2><a name="Content"></a>Content</h2> |
| |
| <ul> |
| |
| <li><a href="#what">What is Web Services (WS) Policy?</a></li> |
| |
| <li><a href="#client">Client Side WS-Policy Support</a></li> |
| |
| <li><a href="#server">Server Side WS-Policy Support</a></li> |
| |
| <li><a href="#resources">Resources</a></li> |
| </ul> |
| <a name="what" id="what"></a> |
| |
| <div class="section"> |
| <h2><a name="What_is_Web_Services_WS_Policy"></a>What is Web Services (WS) Policy?</h2> |
| |
| <p>To consume non trivial web services you must fully understand |
| its XML contract (WSDL) along with any other additional |
| requirements, capabilities, or preferences that translate to the |
| configuration of the service and essentially becomes the policies |
| of the service.</p> |
| |
| <p>WS Policy framework provides a way to express the policies of a |
| service in a machine-readable way. A Web services infrastructure |
| can be enhanced to understand and enforce policies at runtime. For |
| instance, a service author might write a policy requiring a digital |
| signature and encryption, while service consumers can use the |
| policy information to reason out whether they can adhere to this |
| policy information to use the service.</p> |
| |
| <p>Furthermore, Web service infrastructure can be enhanced to |
| enforce those requirements without requiring the service author to |
| write even a single line of code.</p> |
| <a name="client" id="client"></a> |
| |
| <div class="section"> |
| <h2><a name="Client_Side_WS-Policy_Support"></a>Client Side WS-Policy Support</h2> |
| |
| <p>This release <b>fully supports WS Policy at |
| client-side</b>. It means that when you codegen a stub against |
| a WSLD which contains policies, the stub will contain the |
| capability to engage the required modules with the appropriate |
| configurations, plus it will generate additional methods in the |
| stub where the user can set certain properties. For instance, if |
| there is a security policy attached to a binding, the generated |
| stub will engage the security module for that service with the |
| appropriate security configurations with some addtional methods |
| that the user can use to set properties in the generated stub.</p> |
| |
| <div class="section"> |
| <h3><a name="How_it_works:"></a>How it works:</h3> |
| |
| <div class="section"> |
| <h4><a name="Phase_1:_At_PolicyEvaluator"></a>Phase 1: At PolicyEvaluator</h4> |
| |
| <p>The Codegen engine runs a few of its registered extensions |
| before it generates the stub. When the PolicyEvalutor (which is a |
| registered Codegen extension) is initialized, it populates a |
| registry of QNames of supported policy assertions to |
| PolicyExtensions.</p> |
| |
| <p>For instance, module Foo might have a mapping of assertion |
| {http://test.com/foo, foo} which means any assertion that has this |
| name will be processed by this module. The Foo module might |
| implement the ModulePolicyExtension interface through which the |
| PolicyExtension object can be obtained.</p> |
| |
| <p>A <b>PolicyExtension</b> is the access point for a |
| module to add any additional methods to the stub. For instance a |
| Reliable Messaging module can add startSequence() and endSequence() |
| methods to the stub, that the user must call to start and end an RM |
| sequence.</p> |
| |
| <p>Then at the engagement of the PolicyEvaluator, the effective |
| policy of each message of every operation is calculated based on |
| policy information declared in the WSDL document. Here we assume |
| that the effective policy of an operation contains a single |
| alternative (<b>Multiple policy alternatives are not |
| supported</b>). Then we split that policy as follows into few |
| other policies such that, each policy will contain assertions that |
| can be processed by a single module.</p> |
| |
| <div> |
| <pre> |
| <wsp:Policy> <wsp:Policy> <wsp:Policy> |
| <a:Foo/> <a:Foo/> <b:Foo/> |
| <b:Bar/> => </wsp:Policy> |
| </wsp:Policy> |
| </wsp:Policy> |
| </pre></div> |
| |
| <p>Then each policy is given the appropriate PolicyExtension with |
| an org.w3c.Element type object to which the module can append any |
| other elements/attributes it wishes. Those attributes/elements |
| should resolve to meaningful stub functions through the Custom |
| PolicyExtensionTemplate.xsl at a latter point of time.</p> |
| |
| <p>For instance, depending on the policy, the Security module can |
| append <username>, <passwd> elements to the given |
| element as children, which are later resolved into setUsername(..), |
| setPasswd(..), functions of the stub. This way a module can include |
| additional methods to the stub that can be used to get specific |
| propreties from the user. These methods store any user input in the |
| ServiceClient properties |
| (ServiceClient.getOptions().putProperty(...)) which can later be |
| accessed by the module.</p> |
| </div> |
| <div class="section"> |
| <h4><a name="Phase_2:_At_AxisServiceBasedMultiLanguageClientEmitter"></a>Phase 2: At AxisServiceBasedMultiLanguageClientEmitter</h4> |
| |
| <p>Further, policies (based on the WSDL) at appropriate levels |
| (service level, operation level) are stored as policy strings in |
| the stub. If there are a few policies at a given level, they are |
| merged together and represented as a single policy in the stub. Few |
| more generic methods are also added to the stub which are used to |
| evaluate and process the policies at runtime.</p> |
| </div> |
| <div class="section"> |
| <h4><a name="Phase_3:_Runtime"></a>Phase 3: Runtime</h4> |
| |
| <p>When a new stub object is created, the policy strings in the |
| stub are converted into policy objects and are set in the |
| AxisDescription hierarchy that is used in the stub. In other words, |
| any policy information available in the WSDL will be preserved in |
| the AxisService object that is used in the stub.</p> |
| |
| <p>Then based on its policy, each AxisDescription is engaged to a |
| set of modules. Modules can do a prior calculation of |
| configurations if needed at the engagement.</p> |
| |
| <p>When the stub method is invoked, those modules which are engaged |
| to that AxisDescription, access the policy for that operation via |
| the AxisDescription object. It can get the other required |
| information from the MessageContext, which is stored by stub |
| methods that the module has added to the stub earlier, through the |
| ModulePolicyExtension implementation. The modules are required to |
| load their configurations according to the effective policy, which |
| is set at AxisDescription, and the properties they get via |
| MessageContext.</p> |
| <a name="server" id="server"></a> |
| </div></div> |
| <div class="section"> |
| <h2><a name="Server_Side_WS-Policy_Support"></a>Server Side WS-Policy Support</h2> |
| |
| <p>In this current release, the Apache Axis2 framework uses the |
| WS-Commons/Neethi framework to manipulate policy documents. All its |
| description builders store the policy information included in |
| description documents (services.xml, axis2.xml, .. etc) in the |
| appropriate description classes. This information is available at |
| both deployment and run time via these description classes.</p> |
| |
| <p>When generating WSDL dynamically for each service, policy |
| information in the description classes is included. For instance, |
| if you declare a policy in axis2.xml, then that policy is reflected |
| in the service elements of the WSDL of every service. If a policy |
| is declared in a services.xml, it is shown in the service element |
| of WSDL for that particular service.</p> |
| |
| <p>Further, when a service is deployed, an arbitary policy |
| alternative is selected and set for each AxisOperation and |
| AxisMessages of the AxisService. If the selected Policy alternative |
| cannot be supported by any modules that are capable of processing |
| the selective alternative, then the service is considered as a |
| faulty service. Else, the set of modules is engaged at appropriate |
| levels to support the requirments and capabilities that are defined |
| in the Policies associated with the AxisDescription.</p> |
| |
| <p>It is evident that there is some work left to make Apache Axis2 |
| a fully fledged ws-policy supported Web service infrastructure. |
| However, it is encouraging to note that we've taken the first steps |
| towards this goal. We appreciate any suggestions, patches, etc., |
| you send us in this regard. Keep on contributing!</p> |
| <a name="resources" id="resources"></a> |
| |
| <div class="section"> |
| <h2><a name="Resources"></a>Resources</h2> |
| |
| <ul> |
| |
| <li>Apache Neethi (WS Policy Implementation) official site- |
| <a class="externalLink" href="http://ws.apache.org/commons/neethi/index.html">Home Page</a></li> |
| |
| <li>Sanka Samaranayake, March 2006. <a class="externalLink" href="http://wso2.org/library/23">Web services Policy - Why, What & How</a></li> |
| |
| <li><a class="externalLink" href="http://svn.apache.org/viewcvs.cgi/webservices/commons/trunk/modules/neethi/">WS-commons/policy SVN</a></li> |
| |
| <li><a class="externalLink" href="http://specs.xmlsoap.org/ws/2004/09/policy/ws-policy.pdf">Web Services Policy Framework (WS-Policy)</a></li> |
| </ul> |
| |
| </html> |
| </div> |
| </div> |
| </div> |
| <hr/> |
| <footer> |
| <div class="container-fluid"> |
| <div class="row-fluid"> |
| <p>Copyright ©2004–2017 |
| <a href="https://www.apache.org/">The Apache Software Foundation</a>. |
| All rights reserved.</p> |
| </div> |
| </div> |
| </footer> |
| </body> |
| </html> |