You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jason Clark <je...@gmail.com> on 2009/11/11 19:14:34 UTC

AbstractSoapInterceptor can't access Addressing Properties

Hello all,

I'm trying to create an Interceptor that is setup under the following
method:

    public void getStudy(int studyId) {
        try
        {
            MyInterceptor myInterceptor = new MyInterceptor();
            ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
            factory.setServiceClass(OrderServiceSoap.class);
            factory.setAddress("
https://uatwebservice.jcorp.com/OrderService.asmx");
            factory.getFeatures().add(new WSAddressingFeature());
            factory.getOutInterceptors().add( myInterceptor );

            OrderServiceSoap os = (OrderServiceSoap) factory.create();
            os.getStudy( studyid );
        } catch(Exception e) {
            e.printStackTrace();
        }
    }


Below is the code for my Interceptor:

public class MyInterceptor extends AbstractSoapInterceptor {
   public MyInterceptor() {
           super(Phase.PRE_LOGICAL);
           addAfter(MAPAggregator.class.getName());
      }
    public void handleMessage(SoapMessage arg0) throws Fault
    {
        Message message = arg0.getMessage();
        if (ContextUtils.isOutbound(message))
        {
           AddressingPropertiesImpl outMaps =
ContextUtils.retrieveMAPs(message, true, true);
           if (outMaps != null)
           {

outMaps.exposeAs(VersionTransformer.Names200408.WSA_NAMESPACE_NAME);
           }
        }
    }
}

The problem I've encountered is that ContextUtils.retrieveMAPs(message,
true, true) is returning null.

Aside from adding the the WSaddressFeature to to my ClientProxyFactoryBean,
what else do I need to ensure that the address properties are populated when
the interceptor runs?

Cheers,
Jason.

Re: AbstractSoapInterceptor can't access Addressing Properties

Posted by Jason Clark <je...@gmail.com>.
Thanks Dan, that worked like a charm.

Looking at the javadocs, I see

isProviderContext - true if the binding provider request context available
to the client application as opposed to the message context visible to
handlers

With that set to false, it seems the problem was resolved.

2009/11/11 Daniel Kulp <dk...@apache.org>

>
> Try changing:
> ContextUtils.retrieveMAPs(message, true, true);
> to:
> ContextUtils.retrieveMAPs(message, false, true);
>
> If that doesn't work, you may need to dig into the Message contents to see
> what is there:
> for (String s : message.keySet()) {
>   System.out.println(s + "  "  + message.get(s).getClass().getName());
> }
> or so to see what's there.   If the map isn't there, try something like:
>
> System.out.println(message.getInterceptorChain())
> to make sure the MAPAggregator interceptor was really there and in the
> right
> place.
>
>
> Dan
>
>
> On Wed November 11 2009 1:14:34 pm Jason Clark wrote:
> > Hello all,
> >
> > I'm trying to create an Interceptor that is setup under the following
> > method:
> >
> >     public void getStudy(int studyId) {
> >         try
> >         {
> >             MyInterceptor myInterceptor = new MyInterceptor();
> >             ClientProxyFactoryBean factory = new
> ClientProxyFactoryBean();
> >             factory.setServiceClass(OrderServiceSoap.class);
> >             factory.setAddress("
> > https://uatwebservice.jcorp.com/OrderService.asmx");
> >             factory.getFeatures().add(new WSAddressingFeature());
> >             factory.getOutInterceptors().add( myInterceptor );
> >
> >             OrderServiceSoap os = (OrderServiceSoap) factory.create();
> >             os.getStudy( studyid );
> >         } catch(Exception e) {
> >             e.printStackTrace();
> >         }
> >     }
> >
> >
> > Below is the code for my Interceptor:
> >
> > public class MyInterceptor extends AbstractSoapInterceptor {
> >    public MyInterceptor() {
> >            super(Phase.PRE_LOGICAL);
> >            addAfter(MAPAggregator.class.getName());
> >       }
> >     public void handleMessage(SoapMessage arg0) throws Fault
> >     {
> >         Message message = arg0.getMessage();
> >         if (ContextUtils.isOutbound(message))
> >         {
> >            AddressingPropertiesImpl outMaps =
> > ContextUtils.retrieveMAPs(message, true, true);
> >            if (outMaps != null)
> >            {
> >
> > outMaps.exposeAs(VersionTransformer.Names200408.WSA_NAMESPACE_NAME);
> >            }
> >         }
> >     }
> > }
> >
> > The problem I've encountered is that ContextUtils.retrieveMAPs(message,
> > true, true) is returning null.
> >
> > Aside from adding the the WSaddressFeature to to my
> ClientProxyFactoryBean,
> > what else do I need to ensure that the address properties are populated
> >  when the interceptor runs?
> >
> > Cheers,
> > Jason.
> >
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: AbstractSoapInterceptor can't access Addressing Properties

Posted by Daniel Kulp <dk...@apache.org>.
Try changing:
ContextUtils.retrieveMAPs(message, true, true);
to:
ContextUtils.retrieveMAPs(message, false, true);

If that doesn't work, you may need to dig into the Message contents to see 
what is there:
for (String s : message.keySet()) {
   System.out.println(s + "  "  + message.get(s).getClass().getName());
}
or so to see what's there.   If the map isn't there, try something like:

System.out.println(message.getInterceptorChain())
to make sure the MAPAggregator interceptor was really there and in the right 
place.


Dan


On Wed November 11 2009 1:14:34 pm Jason Clark wrote:
> Hello all,
> 
> I'm trying to create an Interceptor that is setup under the following
> method:
> 
>     public void getStudy(int studyId) {
>         try
>         {
>             MyInterceptor myInterceptor = new MyInterceptor();
>             ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
>             factory.setServiceClass(OrderServiceSoap.class);
>             factory.setAddress("
> https://uatwebservice.jcorp.com/OrderService.asmx");
>             factory.getFeatures().add(new WSAddressingFeature());
>             factory.getOutInterceptors().add( myInterceptor );
> 
>             OrderServiceSoap os = (OrderServiceSoap) factory.create();
>             os.getStudy( studyid );
>         } catch(Exception e) {
>             e.printStackTrace();
>         }
>     }
> 
> 
> Below is the code for my Interceptor:
> 
> public class MyInterceptor extends AbstractSoapInterceptor {
>    public MyInterceptor() {
>            super(Phase.PRE_LOGICAL);
>            addAfter(MAPAggregator.class.getName());
>       }
>     public void handleMessage(SoapMessage arg0) throws Fault
>     {
>         Message message = arg0.getMessage();
>         if (ContextUtils.isOutbound(message))
>         {
>            AddressingPropertiesImpl outMaps =
> ContextUtils.retrieveMAPs(message, true, true);
>            if (outMaps != null)
>            {
> 
> outMaps.exposeAs(VersionTransformer.Names200408.WSA_NAMESPACE_NAME);
>            }
>         }
>     }
> }
> 
> The problem I've encountered is that ContextUtils.retrieveMAPs(message,
> true, true) is returning null.
> 
> Aside from adding the the WSaddressFeature to to my ClientProxyFactoryBean,
> what else do I need to ensure that the address properties are populated
>  when the interceptor runs?
> 
> Cheers,
> Jason.
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog