Hi dear all,

I'm developing a custom ws-policy by using cxf. Everything works fine,
except I see when I add wsp:Optional=true in my custom policy in wsdl, I can
get assertion in my client out interceptor, but cannot get in the server
side in interceptor, The AssertionMap is null, I see there is also some
question about the Optional setting problem in ws-addressing in forum. Not
sure anyone can help me take a look if there is something wrong in my config
or some is some issue in cxf? Appreciate it! :)

My Assertion is very sample, just need to check isOptioanl and isIgnorable.
no need any other element check.

Here is my step:
*1, Create a my AssertionBuilder, in check Optional and Ignorable value in
build method and generate a new Assertion:*
public class MyAssertionBuilder implements AssertionBuilder<Element>{
    public Assertion build(Element element, AssertionBuilderFactory factory)
                    throws IllegalArgumentException {
Dummy code:
Assertion assertion = new Assertion();
assertion.setOptional(PolicyConstants.isOptional(element));
assertion.setIgnorable(PolicyConstants.isIgnorable(element));
return assertion
.....


*2, Create an Interceptor to assert my Assertion:*
    public void handleMessage(SoapMessage message) throws Fault
    {
        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
        if (null == aim)
        {
            return;
        }

        Collection<AssertionInfo> ais = aim.get(My.ASSERTION_QNAME);
        if (null == ais || ais.size() == 0)
        {
            return;
        }
        for (AssertionInfo ai : ais)
        {
            ai.setAsserted(true);
        }
    }


3, Create my PolicyBuilder to add Interceptor in in and out for my
ASSERTION_TYPES:
    public MyAssertionPolicyProvider() {
        super(ASSERTION_TYPES);
        getInInterceptors().add(IN_INTERCEPTOR);
        getOutInterceptors().add(OUT_INTERCEPTOR);
...

Add InInterceptor in phase PRE_PROTOCOL and also outInterceptor in phase
PRE_PROTOCOL


4, Add them in cxf-extensions.txt file.


Then I verify my policy, when debug in out MyPolicyInterceptor in client
side, AssertionInfoMap is not null, I can get my Assertion successfully.

But when running in server side in in MyPolicyInterceptor, the
AssertionInfoMap is null, I cannot get Assertion, its' null....


So I'm confuse why after set wsp:Optional=true everything works in out
Interceptor in client side and not work in in Interceptor in server side.
But if set wsp:Optional=false or doesn't set Optional parameter, everything
works fine in both side.


Not sure if there is issue in cxf for Optional=true situation?

Or could you please let me know if there is any way to debug or narrow down
my problem?

Great thanks a lot! :)



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Cannot-get-ws-policy-assertion-when-wsp-Optional-set-true-tp5758740.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to