Hi,
OK, now I get your question: you would like to modify WS-A headers on the
server side in the same way as for the client, correct?
You surely achieve this in interceptor, I just warn that you interceptor will
set ALL soap headers to must understand, not only WSA once.
Alternative, you can do this on the server side in business code using the
WebServiceContext. Code will look like:
@Resource
private WebServiceContext wsContext;
...
final MessageContext mc = wsContext.getMessageContext();
AddressingProperties maps = new AddressingPropertiesImpl();
List<QName> mustUnderstandList = maps.getMustUnderstand();
mustUnderstandList.add(Names.WSA_ACTION_QNAME);
mustUnderstandList.add(Names.WSA_TO_QNAME);
mc.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps);
Regards,
Andrei.
> -----Original Message-----
> From: Alx [mailto:[email protected]]
> Sent: Mittwoch, 8. April 2015 07:53
> To: [email protected]
> Subject: Re: How to set mustUnderstand attribute in WS-Addressing headers
>
> By default mustUnderstand headers are not set when using WS-SecurityPolicy.
>
> I ended up using an interceptor for this, both in the client and server:
>
> public class AddressingMustUnderstandInterceptor extends
> AbstractSoapInterceptor {
>
> public AddressingMustUnderstandInterceptor () {
> super(Phase.WRITE);
> }
>
> @Override
> public void handleMessage (SoapMessage message) throws Fault {
> List <Header> list = message.getHeaders();
> list.stream().forEach(header -> ((SoapHeader)
> header).setMustUnderstand(true));
> }
>
> }
>
> On Tue, Apr 7, 2015 at 6:28 PM, Andrei Shakirin <[email protected]>
> wrote:
>
> > Hi,
> >
> > Some answers are inlined:
> >
> > > -----Original Message-----
> > > From: Alx [mailto:[email protected]]
> > > Sent: Donnerstag, 2. April 2015 14:54
> > > To: [email protected]
> > > Subject: How to set mustUnderstand attribute in WS-Addressing
> > > headers
> > >
> > > Requirement from my client is to set the mustUnderstand atrribute to "1"
> > in To-
> > > Element and Action-Element of WS-Addressing.
> > >
> > > I managed to do that on the client using the following:
> > >
> > > AddressingProperties maps = new AddressingPropertiesImpl();
> > > List<QName> mustUnderstandList = maps.getMustUnderstand();
> > > mustUnderstandList.add(Names.WSA_ACTION_QNAME);
> > > mustUnderstandList.add(Names.WSA_TO_QNAME);
> > > ctx.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps);
> > >
> > > (By the way this sets the mustUnderstand attribute to "true" and not
> > > to
> > "1"
> > > I suppose that it is the same thing?)
> >
> > Specified value is "true", but intermediaries be able to substitute "true"
> > for the value "1", or "false" for "0". See
> > http://www.w3.org/TR/2003/REC-soap12-part1-20030624 (SOAP
> > mustUnderstand
> > Attribute) for details.
> >
> > >
> > > On the server I am not sure how to proceed.
> > >
> > > Also I would prefer if there was a standard way to do it (i.e.
> > > WS-SecurityPolicy or maybe CXF interceptor used in both the client
> > > and
> > the
> > > server?)
> >
> > You can either explicitly add WS-Addressing feature on the server and
> > client or activate WSA using WS-Policy <Addressing> assertion:
> > http://cxf.apache.org/docs/ws-addressing.html . Take a look here for
> > the
> > samples:
> > https://github.com/apache/cxf/tree/master/distribution/src/main/releas
> > e/samples/ws_addressing
> >
> > Regards,
> > Andrei.
> >
> > >
> > > Any help will be appreciated.
> > >
> > > Alex
> >