Thanks again Eoghan,

How do I go about setting the values that are retrieved by ContextUtils in
my Interceptor?

I've created my addressing properties with:

            Map<String, Object> requestContext =
((BindingProvider)port).getRequestContext();
            AddressingProperties maps = new AddressingPropertiesImpl();
            requestContext.put(CLIENT_ADDRESSING_PROPERTIES, maps);

            AttributedURIType messageID =
WSA_OBJECT_FACTORY.createAttributedURIType();
            messageID.setValue("urn:uuid:" + System.currentTimeMillis());
            maps.setMessageID(messageID);

            Map<String, Object> requestContext = new HashMap<String,
Object>();
            requestContext.put(CLIENT_ADDRESSING_PROPERTIES, maps);

            factory.setProperties( requestContext );


But at the Interceptor portion, ContextUtils.isOutbound(message) always
returns false, and ContextUtils.retrieveMAPs(message, true, true) returns
null.  I feel like I'm missing something fundamental here from a
configuration standpoint.


Cheers,
Jason.



2009/11/4 Eoghan Glynn <[email protected]>

> > Unless I'm mistaken, I should
> > try to modify the message at the WRITE phase?
>
> No, that would be too late as the WS-A codec interceptor would have already
> run in the PRE_PROTOCOL phase, i.e. the message addressing properties would
> already have been marshalled up using the default WS-A version by the time
> your WRITE interceptor runs.
>
> So probably best to run it in the same phase as the WS-A interceptor
> responsible for aggregating the properties, straight after that interceptor
> has been traversed:
>
> public class MyInterceptor extends AbstractSoapInterceptor {
>     public MyInterceptor() {
>         super(Phase.PRE_LOGICAL);
>        addAfter(MAPAggregator.class.getName());
>     }
>
> You also need to be careful that you only modify on the outbound leg, so
> handleMessage should probably look something like:
>
>   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);
>         }
>      }
>   }
>
> Cheers,
> Eoghan
>
> 2009/11/3 Jason Clark <[email protected]>
>
> > Thanks Eoghan,
> >
> > Maybe I'll try to go the interceptor route.  Unless I'm mistaken, I
> should
> > try to modify the message at the WRITE phase?
> >
> > I've updated my code:
> >
> >            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( 234 );
> >
> > where my interceptor class is:
> >
> > public class MyInterceptor extends AbstractSoapInterceptor {
> >      public MyInterceptor() {
> >        super(Phase.WRITE);
> >      }
> >
> >    @Override
> >    public void handleMessage(SoapMessage arg0) throws Fault
> >    {
> >        AddressingPropertiesImpl inMaps =
> > RMContextUtils.retrieveMAPs(arg0.getMessage(),false, false);
> >
> > inMaps.exposeAs(VersionTransformer.Names200408.WSA_NAMESPACE_NAME);
> >    }
> > }
> >
> > which is throwing the exception:
> >
> > WARNING: WS-Addressing - failed to retrieve Message Addressing Properties
> > from context
> > Nov 3, 2009 2:17:26 PM org.apache.cxf.phase.PhaseInterceptorChain
> > doIntercept
> > WARNING: Interceptor has thrown exception, unwinding now
> >
> >
> > I thought this:
> > factory.getFeatures().add( new WSAddressingFeature() );
> >
> > would create the addressing properties?  I think I missing something
> pretty
> > major here.
> >
> > Cheers,
> > Jason.
> >
> >
> >
> > 2009/11/3 Eoghan Glynn <[email protected]>
> >
> > > Jason,
> > >
> > > Our support for WS-A 2004/08 was added specifically for the CXF WS-RM
> > > implementation, as WS-RM 1.0 depended on that older version of WS-A.
> > >
> > > As a result the mechanism for enabling this feature is a tad
> unfriendly,
> > > requiring an API call on the AddressingProperties to specify the WS-A
> > > version you require.
> > >
> > > See for example how the WS-RM code calls this exposeAs() API:
> > >
> > >
> > >
> >
> http://svn.apache.org/repos/asf/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
> > >
> > > AddressingPropertiesImpl inMaps = RMContextUtils.retrieveMAPs(message,
> > > false, false);
> > >
> > > inMaps.exposeAs(VersionTransformer.Names200408.WSA_NAMESPACE_NAME);
> > >
> > > You could write a simple interceptor to run after the WS-A
> MapAggregator
> > > which takes a similar approach to the above.
> > >
> > > Cheers,
> > > Eoghan
> > >
> > >
> > > 2009/11/3 Jason Clark <[email protected]>
> > >
> > > > Hello all,
> > > >
> > > > Has anyone here had an opportunity to use the 2004/08 version of
> > > > WS-Addressing  (http://schemas.xmlsoap.org/ws/2004/08/addressing).
> > > >
> > > > The service I'm attempting to connect to will only accept that
> version.
> > >  I
> > > > see on http://cwiki.apache.org/CXF20DOC/ws-addressing.html that "CXF
> > > > provides support for the 2004-08 and 1.0 versions of WS-Addressing.",
> > but
> > > > haven't been able to determine what it is I need to do to change it.
> > > >
> > > > In Axis2 1.4, I'm able to explicitly specify the version by :
> > > >
> > > >
> > > >
> > >
> >
> options.setProperty(org.apache.axis2.addressing.AddressingConstants.WS_ADDRESSING_VERSION,
> > > >
> > >
> >
> org.apache.axis2.addressing.AddressingConstants.Submission.WSA_NAMESPACE);
> > > >
> > > >
> > > > With CXF, I've set up WS-Addressing with:
> > > >
> > > >            ClientProxyFactoryBean factory = new
> > ClientProxyFactoryBean();
> > > >            factory.setServiceClass(OrderServiceSoap.class);
> > > >            factory.setAddress("
> > > > https://webservice.jcorp.com/OrderService.asmx";);
> > > >            factory.getFeatures().add(new WSAddressingFeature() );
> > > >
> > > >  And when I examine the raw request, I see:
> > > >
> > > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/
> ">
> > > >    <soap:Header>
> > > >        <Action xmlns="*http://www.w3.org/2005/08/addressing*";>
> > > >
> http://service.jcorp.com/OrderServiceSoapPortType/getStudy
> > > >        </Action>
> > > >        <MessageID xmlns="*http://www.w3.org/2005/08/addressing*";>
> > > >            urn:uuid:a559ae80-d667-4795-8d74-3e3c2319d1b3</MessageID>
> > > >        <To xmlns="http://www.w3.org/2005/08/addressing";>
> > > > https://service.jcorp.com/OrderService.asmx
> > > >        </To>
> > > >        <ReplyTo xmlns="http://www.w3.org/2005/08/addressing";>
> > > >            <Address>http://www.w3.org/2005/08/addressing/anonymous
> > > >            </Address>
> > > >        </ReplyTo>
> > > >    </soap:Header>
> > > >    <soap:Body>
> > > >        <ns1:getStudy xmlns:ns1="http://service.jcorp.com/";>
> > > >            <ns2:arg0 xmlns="http://jcorp.com/service";
> > > >                xmlns:ns2="http://service.jcorp.com/";>234</ns2:arg0>
> > > >        </ns1:getStudy>
> > > >    </soap:Body>
> > > > </soap:Envelope>
> > > >
> > > > So it's attempting to do the right thing.  Could someone please point
> > me
> > > in
> > > > the right direction?
> > > >
> > >
> >
>

Reply via email to