5

我正在尝试使用 Apache CXF 2.7.18 实现 WS-Addressing。我可以设置一些标题,如 To、Action 等。但我想从 SOAP 请求中删除/删除 ReplyTo

<Action xmlns="http://www.w3.org/2005/08/addressing">http://...</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:....</MessageID>
<To xmlns="http://www.w3.org/2005/08/addressing">https://....</To>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
        <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>

有人知道怎么做吗?

4

1 回答 1

1

我找到了一个解决方案,即使它有点脏,但它对我有用。我已明确将其设置为“null”(使用 Cxf 和 JaxWsProxyFactoryBean)。

    EndpointReferenceType replyTo = new EndpointReferenceType();
    AddressingProperties addrProperties = new AddressingProperties();
    AttributedURIType replyToURI = new AttributedURIType();

    EndpointReferenceType from = new EndpointReferenceType();
    AttributedURIType fromURI = new AttributedURIType();
    fromURI.setValue("ms-register");
    from.setAddress(fromURI);
    addrProperties.setFrom(from);
    addrProperties.setFrom(from);

    replyToURI.setValue(null);
    replyTo.setAddress(replyToURI);
    addrProperties.setReplyTo(replyTo);
    client.getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES,addrPropertie);
于 2020-03-23T14:11:50.313 回答