Apache CXF - WS 解决如何设置 From、ReplyTo、Headers

Posted

技术标签:

【中文标题】Apache CXF - WS 解决如何设置 From、ReplyTo、Headers【英文标题】:Apache CXF - WS addressing how to set From, ReplyTo, Headers 【发布时间】:2015-02-09 17:10:54 【问题描述】:

我有一个问题:我们正在尝试使用 Apache CXF 实现 WS-Addressing。我可以设置一些标头,例如 To 或 Action,但我找不到设置其他标头的方法,例如 From、ReplyTo 或 FaultTo。

有人知道怎么做吗?

【问题讨论】:

【参考方案1】:

看看http://cxf.apache.org/docs/ws-addressing.html。它在页面的末尾:

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);

亲切的问候,土工

【讨论】:

作为注释,ep.getFeatures().add(new WSAddressingFeature());应该在创建之前添加到客户端代理工厂。没有它上面的代码不会添加地址信息

以上是关于Apache CXF - WS 解决如何设置 From、ReplyTo、Headers的主要内容,如果未能解决你的问题,请参考以下文章