Apache CXF - WS addressing how to set From, ReplyT

2019-06-24 01:53发布

问题:

I have a question: we are trying to implement WS-Addressing with Apache CXF. I am able to set some headers like To, or Action, but I don't find the way to set others like From, ReplyTo, or FaultTo.

Does anybody know how to do it?

回答1:

Take a look at http://cxf.apache.org/docs/ws-addressing.html. It's on the end of the page:

AddressingProperties maps = new AddressingPropertiesImpl();
EndpointReferenceType ref = new EndpointReferenceType();
AttributedURIType add = new AttributedURIType();
add.setValue("http://localhost:9090/decoupled_endpoint");
ref.setAddress(add);
maps.setReplyTo(ref);
maps.setFaultTo(ref);

((BindingProvider)port).getRequestContext()
    .put("javax.xml.ws.addressing.context", maps);

kind regards, soilworker