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/03 17:37:25 UTC

Using WS-Addressing 2004/08

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?

Re: Using WS-Addressing 2004/08

Posted by Jason Clark <je...@gmail.com>.
Also, just to clarify.

When you say "The MAPAggregator should be installed as a side-effect of
setting the WSAddressingFeature". I'm accomplishing that with this :

factory.getFeatures().add(new WSAddressingFeature());

Cheers,
Jason.




2009/11/9 Jason Clark <je...@gmail.com>

> Thanks Eoghan,
>
> Here's my cxf config:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xmlns:jaxws="http://cxf.apache.org/jaxws"
>       xmlns:cxf="http://cxf.apache.org/core"
>       xmlns:wsa="http://cxf.apache.org/ws/addressing"
>       xmlns:http="http://cxf.apache.org/transports/http/configuration"
>       xsi:schemaLocation="http://cxf.apache.org/core
> http://cxf.apache.org/schemas/core.xsd
>        http://cxf.apache.org/transports/http/configuration
> http://cxf.apache.org/schemas/configuration/http-conf.xsd
>        http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
> ">
>
>     <import resource="classpath:META-INF/cxf/cxf.xml" />
>     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
>     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
>     <bean id="logOutbound"
> class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
>
>     <bean id="mapAggregator"
> class="org.apache.cxf.ws.addressing.MAPAggregator">
>         <property name="allowDuplicates" value="false"/>
>     </bean>
>     <bean id="mapCodec"
> class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>
>
>     <jaxws:client id="com.jcorp.service.OrderServiceSoap">
>       <jaxws:features>
>         <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing"/>
>       </jaxws:features>
>     </jaxws:client>
>
>     <cxf:bus>
>         <cxf:inInterceptors>
>             <ref bean="mapAggregator"/>
>             <ref bean="mapCodec"/>
>         </cxf:inInterceptors>
>         <cxf:inFaultInterceptors>
>             <ref bean="mapAggregator"/>
>             <ref bean="mapCodec"/>
>         </cxf:inFaultInterceptors>
>         <cxf:outInterceptors>
>             <ref bean="mapAggregator"/>
>             <ref bean="mapCodec"/>
>         </cxf:outInterceptors>
>         <cxf:outFaultInterceptors>
>             <ref bean="mapAggregator"/>
>             <ref bean="mapCodec"/>
>         </cxf:outFaultInterceptors>
>
>         <cxf:features>
>             <wsa:addressing/>
>              <cxf:logging/>
>         </cxf:features>
>     </cxf:bus>
>
> </beans>
>
> And I'm seeing this in the logs:
>
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@ec4a87:
> defining beans
> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.corba.CorbaBindingFactory,org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister#0,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.javascript.JavascriptQueryHandlerRegistry,org.apache.cxf.transport.local.LocalTransportFactory,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.management.InstrumentationManager,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory,org.apache.cxf.transport.jms.JMSTransportFactory,org.apache.cxf.binding.object.ObjectBindingFactory,org.apache.cxf.binding.http.HttpBindingFactory,org.apache.cxf.jaxrs.JAXRSBindingFactory,org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader,org.apache.cxf.ws.policy.AssertionBuilderRegistry,org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry,org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry,org.apache.cxf.ws.policy.attachment.external.EndpointReferenceDomainExpressionBuilder,org.apache.cxf.ws.policy.PolicyBuilder,org.apache.cxf.ws.policy.PolicyEngine,org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider,org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider,org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder,org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMManager,org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMAssertionBuilder,org.apache.cxf.transport.servlet.ServletTransportFactory,logOutbound,mapAggregator,mapCodec,com.telmetrics.perspectica.service.OrderServiceSoap.proxyFactory,com.telmetrics.perspectica.service.OrderServiceSoap,cxf.config];
> root of factory hierarchy
>
> Following the instructions at:
> http://cxf.apache.org/docs/wsaconfiguration.html, I'm fairly certain I've
> accomplished the first task, maybe my issue is with the 2nd.
>
> The use of WS-Addressing is indicated by one of the following:
>
>    1. A <UsingAddressing xmlns="http://www.w3.org/2005/02/addressing/wsdl">
>    element is attached to the <wsdl:port>, <wsdl:service> or <wsdl:binding>
>    element.
>    2. The (chosen alternative for the) effective policy of the message
>    contains a <Addressing xmlns="
>    http://www.w3.org/2007/02/addressing/metadata"> assertion or a
>    <UsingAddressing> assertion from either one of the following three
>    namespaces: http://schemas.xmlsoap.org/ws/2004/08/addressing/policy,
>    http://www.w3.org/2005/02/addressing/wsdl,
>    http://www.w3.org/2006/05/addressing/wsdl.
>    3. Property org.apache.cxf.ws.addressing.using in the message context
>    is set to Boolean.TRUE.
>
>
> From a configuration perspective, do you say anything glaringly obvious
> that might be causing my problem?
>
>
>
> 2009/11/9 Eoghan Glynn <eo...@gmail.com>
>
> Jason,
>>
>> You shouldn't have to create the message properties explicitly. This
>> should
>> be done by the CXF WS-Addressing MAPAggregator interceptor (that runs
>> *before* your custom interceptor). The MAPAggregator should be installed
>> as
>> a side-effect of setting the WSAddressingFeature. Can you bump up logging
>> to
>> the max to ensure the MAPAggregator is actually being traversed?
>>
>> /Eoghan
>>
>> 2009/11/9 Jason Clark <je...@gmail.com>
>>
>> > 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 <eo...@gmail.com>
>> >
>> > > > 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 <je...@gmail.com>
>> > >
>> > > > 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 <eo...@gmail.com>
>> > > >
>> > > > > 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 <je...@gmail.com>
>> > > > >
>> > > > > > 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?
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>>
>
>

Re: Using WS-Addressing 2004/08

Posted by Jason Clark <je...@gmail.com>.
Thanks Eoghan,

Here's my cxf config:

<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jaxws="http://cxf.apache.org/jaxws"
      xmlns:cxf="http://cxf.apache.org/core"
      xmlns:wsa="http://cxf.apache.org/ws/addressing"
      xmlns:http="http://cxf.apache.org/transports/http/configuration"
      xsi:schemaLocation="http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
       http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

    <bean id="logOutbound"
class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

    <bean id="mapAggregator"
class="org.apache.cxf.ws.addressing.MAPAggregator">
        <property name="allowDuplicates" value="false"/>
    </bean>
    <bean id="mapCodec" class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>

    <jaxws:client id="com.jcorp.service.OrderServiceSoap">
      <jaxws:features>
        <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing"/>
      </jaxws:features>
    </jaxws:client>

    <cxf:bus>
        <cxf:inInterceptors>
            <ref bean="mapAggregator"/>
            <ref bean="mapCodec"/>
        </cxf:inInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="mapAggregator"/>
            <ref bean="mapCodec"/>
        </cxf:inFaultInterceptors>
        <cxf:outInterceptors>
            <ref bean="mapAggregator"/>
            <ref bean="mapCodec"/>
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="mapAggregator"/>
            <ref bean="mapCodec"/>
        </cxf:outFaultInterceptors>

        <cxf:features>
            <wsa:addressing/>
             <cxf:logging/>
        </cxf:features>
    </cxf:bus>

</beans>

And I'm seeing this in the logs:

INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@ec4a87:
defining beans
[cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.corba.CorbaBindingFactory,org.apache.cxf.binding.corba.wsdl.WSDLExtensionRegister#0,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.javascript.JavascriptQueryHandlerRegistry,org.apache.cxf.transport.local.LocalTransportFactory,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.management.InstrumentationManager,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory,org.apache.cxf.transport.jms.JMSTransportFactory,org.apache.cxf.binding.object.ObjectBindingFactory,org.apache.cxf.binding.http.HttpBindingFactory,org.apache.cxf.jaxrs.JAXRSBindingFactory,org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader,org.apache.cxf.ws.policy.AssertionBuilderRegistry,org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry,org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry,org.apache.cxf.ws.policy.attachment.external.EndpointReferenceDomainExpressionBuilder,org.apache.cxf.ws.policy.PolicyBuilder,org.apache.cxf.ws.policy.PolicyEngine,org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider,org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider,org.apache.cxf.ws.policy.mtom.MTOMAssertionBuilder,org.apache.cxf.ws.policy.mtom.MTOMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMManager,org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider,org.apache.cxf.ws.rm.RMAssertionBuilder,org.apache.cxf.transport.servlet.ServletTransportFactory,logOutbound,mapAggregator,mapCodec,com.telmetrics.perspectica.service.OrderServiceSoap.proxyFactory,com.telmetrics.perspectica.service.OrderServiceSoap,cxf.config];
root of factory hierarchy

Following the instructions at:
http://cxf.apache.org/docs/wsaconfiguration.html, I'm fairly certain I've
accomplished the first task, maybe my issue is with the 2nd.

The use of WS-Addressing is indicated by one of the following:

   1. A <UsingAddressing xmlns="http://www.w3.org/2005/02/addressing/wsdl">
   element is attached to the <wsdl:port>, <wsdl:service> or <wsdl:binding>
   element.
   2. The (chosen alternative for the) effective policy of the message
   contains a <Addressing xmlns="
   http://www.w3.org/2007/02/addressing/metadata"> assertion or a
   <UsingAddressing> assertion from either one of the following three
   namespaces: http://schemas.xmlsoap.org/ws/2004/08/addressing/policy,
   http://www.w3.org/2005/02/addressing/wsdl,
   http://www.w3.org/2006/05/addressing/wsdl.
   3. Property org.apache.cxf.ws.addressing.using in the message context is
   set to Boolean.TRUE.


>From a configuration perspective, do you say anything glaringly obvious that
might be causing my problem?



2009/11/9 Eoghan Glynn <eo...@gmail.com>

> Jason,
>
> You shouldn't have to create the message properties explicitly. This should
> be done by the CXF WS-Addressing MAPAggregator interceptor (that runs
> *before* your custom interceptor). The MAPAggregator should be installed as
> a side-effect of setting the WSAddressingFeature. Can you bump up logging
> to
> the max to ensure the MAPAggregator is actually being traversed?
>
> /Eoghan
>
> 2009/11/9 Jason Clark <je...@gmail.com>
>
> > 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 <eo...@gmail.com>
> >
> > > > 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 <je...@gmail.com>
> > >
> > > > 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 <eo...@gmail.com>
> > > >
> > > > > 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 <je...@gmail.com>
> > > > >
> > > > > > 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?
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Using WS-Addressing 2004/08

Posted by Eoghan Glynn <eo...@gmail.com>.
Jason,

You shouldn't have to create the message properties explicitly. This should
be done by the CXF WS-Addressing MAPAggregator interceptor (that runs
*before* your custom interceptor). The MAPAggregator should be installed as
a side-effect of setting the WSAddressingFeature. Can you bump up logging to
the max to ensure the MAPAggregator is actually being traversed?

/Eoghan

2009/11/9 Jason Clark <je...@gmail.com>

> 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 <eo...@gmail.com>
>
> > > 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 <je...@gmail.com>
> >
> > > 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 <eo...@gmail.com>
> > >
> > > > 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 <je...@gmail.com>
> > > >
> > > > > 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?
> > > > >
> > > >
> > >
> >
>

Re: Using WS-Addressing 2004/08

Posted by Jason Clark <je...@gmail.com>.
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 <eo...@gmail.com>

> > 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 <je...@gmail.com>
>
> > 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 <eo...@gmail.com>
> >
> > > 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 <je...@gmail.com>
> > >
> > > > 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?
> > > >
> > >
> >
>

Re: Using WS-Addressing 2004/08

Posted by Eoghan Glynn <eo...@gmail.com>.
> 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 <je...@gmail.com>

> 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 <eo...@gmail.com>
>
> > 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 <je...@gmail.com>
> >
> > > 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?
> > >
> >
>

Re: Using WS-Addressing 2004/08

Posted by Jason Clark <je...@gmail.com>.
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 <eo...@gmail.com>

> 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 <je...@gmail.com>
>
> > 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?
> >
>

Re: Using WS-Addressing 2004/08

Posted by Eoghan Glynn <eo...@gmail.com>.
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 <je...@gmail.com>

> 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?
>