3 Replies Latest reply on Oct 6, 2010 9:12 AM by asoldano

    CXF Policy Engine

    ropalka

      Hi Folks,

       

         I'll be little bit verbose about the setup because I don't know how much Sergey is familiar with our test framework.

         I just commited first JBWS-3134 related test case to the framework.

      This test case allows U to reproduce the CXF Policy engine issue we've been discussing on IRC yesterday.

      In order to reproduce the issue I suggest U to modify

       

      framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws3134/AddrFeaturesViaAnn/JBWS3134TestCase.java

       

      and comment out all test test methods except testVerifyAddrHeadersExistForRequiredEchoPort() one.

      Then do mvn clean install of this modified framework to your local maven repository so it's picked up by CXF tests.

      U will also need to configure JBossAS to be debuggable (just comment out one line in $JBOSS_HOME/bin/run.conf)

       

      Here are the breakpoints U should set up in your IDE:

      * org.apache.cxf.ws.policy.EffectivePolicy

         - void chooseAlternative(PolicyEngineImpl engine, Assertor assertor) // [1]

      * org.apache.cxf.ws.Policy.PolicyEngineImpl

         - public synchronized AlternativeSelector getAlternativeSelector() // [2]

       

      To run just this one test do:

      * if executed first time

         - [../cxf/trunk]>mvn -Ptestsuite,spring,hudson,jboss601 test -Dtest=**/jaxws/jbws3134/**/*TestCase

      * if executed not first time (to save some time)

         - [../cxf/trunk]>mvn -Ptestsuite,spring,hudson,jboss601 test -Dtest=**/jaxws/jbws3134/**/*TestCase -Dnoprepare

       

      IDENTIFIED ISSUE

       

      I've been debugging this issue and here are my investigation results:

       

      If I set wsp:Optional="false" in

      cxf/trunk/modules/testsuite/framework-tests/target/test-libs/jaxws-jbws3134-addrfeaturesviaann-endpoint.war!/WEB-INF/wsdl/EchoService.wsdl

      before running test then there's only one policy alternative associated with EchoImpl - addressing.

       

      If I set wsp:Optional="true" in

      cxf/trunk/modules/testsuite/framework-tests/target/test-libs/jaxws-jbws3134-addrfeaturesviaann-endpoint.war!/WEB-INF/wsdl/EchoService.wsdl

      then there're two policy alternatives created and associated with EchoImpl - addressing & empty one.

       

      With PolicyEngineImpl used on endpoint side there's no policy AlternativeSelector configured so MinimalAlternativeSelector is instantiated and used (see [2] breakpoint in your IDE). This org.apache.cxf.ws.policy.selector.MinimalAlternativeSelector simply picks up empty assertion

      if wsp:Optional="true" is specified in WSDL.

       

      SUGGESTED SOLUTIONS?

       

      This is the question I wanna discuss with U

      The problem that I see is PolicyAlternativeSelector is not taking incomming SOAP envelope content into account.

      This said if some policy is optional, CXF should be able to somehow inspect incoming SOAP envelopes and pick up proper policy alternative for it.

      I see there are three default AlternativeSelector implementations in CXF:

       

      [/home/opalka][/home/opalka/THIRDPARTY/CXF/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector]>ls -al | grep java
      FirstAlternativeSelector.java
      MaximalAlternativeSelector.java
      MinimalAlternativeSelector.java

       

      But none of it is taking incoming SOAP envelope content into account thus sometimes picking up wrong policy alternative.

      The question is what should do this SOAP envelope inspection. AlternativeSelector or PolicyEngine?

       

      I see that org.apache.cxf.ws.policy.PolicyEngine have these methods:

       

      * EffectivePolicy getEffectiveServerRequestPolicy(EndpointInfo ei, BindingOperationInfo boi)

      * EffectivePolicy getEffectiveServerResponsePolicy(EndpointInfo ei, BindingOperationInfo boi, Destination d);

       

      Should these methods inspect incomming SOAP envelope and filter out effective policy alternatives before passing them to AlternativeSelector?

       

      Thanks in advance for your feedback.

        • 1. Re: CXF Policy Engine
          ropalka

          To be more precise, current issue is:

           

          Client sends WSA headers to WSA enabled endpoint.

          WSA is optional in WSDL and CXF is picking up empty policy alternative

          for endpoint and thus responding without WSA headers to the client.

           

          It's expected that WSA headers are in the server response if client sends them and WSA is optional in WSDL.

          • 2. Re: CXF Policy Engine
            asoldano

            Btw, explicitly setting the current bus for using a maximal policy alternative makes that specific test pass, but of course others start failing. As Sergey just confirmed on IRC, a static choice of server side selector is generally not good, the engine should be able to decide what alternative to use depending on the incoming message.

            • 3. Re: CXF Policy Engine
              asoldano