相关疑难解决方法(0)

如何修改生成的SOAP请求?

我正处于创建输出拦截器的阶段,我从SOAP消息中获取了一个OuputStream.但是如何在将SOAP信封发送到端点之前修改它呢?我想删除一些xml元素.

java cxf outputstream interceptor

9
推荐指数
1
解决办法
1万
查看次数

在加密之前修改 CXF RequestSecurityToken 的 XML

我正在使用 Apache CXF 从 Java 客户端调用 WCF 服务。使用另一个地址的 STS 来保护服务的安全。我已将服务客户端配置为在调用主服务之前调用安全令牌,并且它可以工作(它尝试调用 STS),但 STS 期望在元素中提供一些额外的数据RequestSecurityToken。STS 的策略指定RequestSecurityToken在发送之前对其进行加密和签名,这就是导致我出现问题的原因。加密和签名正在工作,但我似乎无法在加密之前修改 SOAP 消息。

我查看了这个问题:如何修改出站 CXF 请求的原始 XML 消息?虽然它有很大帮助,但我需要更改的 XML 部分位于已加密和签名的 SOAP 消息的一部分内。

我做了一个Interceptor并在我能找到的所有不同阶段进行了尝试,但在RequestSecurityToken创建和加密和签名之间似乎没有一个阶段被调用。

有吗?或者已经有一个可以向其中添加额外元素的工具RequestSecurityToken

为了清楚起见编辑:

这是我的 RST 现在的样子:

<wst:RequestSecurityToken xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
    <wst:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</wst:RequestType>
    <wsp:AppliesTo xmlns:wsp="http://www.w3.org/ns/ws-policy">
        <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
            <wsa:Address>http://localhost:9085/MyService</wsa:Address>
        </wsa:EndpointReference>
    </wsp:AppliesTo>
    <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>
    <wst:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/SymmetricKey</wst:KeyType>
    <wst:KeySize>192</wst:KeySize>
    <wst:Entropy>
        <wst:BinarySecret Type="http://docs.oasis-open.org/ws-sx/ws-trust/200512/Nonce">OlbfbuCUf3N2lNf9mhD03gfeMk0TfPI2nLWx8edlL5w=</wst:BinarySecret>
    </wst:Entropy>
    <wst:ComputedKeyAlgorithm>http://docs.oasis-open.org/ws-sx/ws-trust/200512/CK/PSHA1</wst:ComputedKeyAlgorithm>
    <wst:Renewing/>
</wst:RequestSecurityToken>
Run Code Online (Sandbox Code Playgroud)

以下是服务提供商的文档所说的大致内容(请注意Credentials末尾附近的元素):

<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
    <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
    <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
            <Address>http://localhost:9085/MyService</Address>
        </EndpointReference>
    </wsp:AppliesTo>
    <t:Entropy>
        <t:BinarySecret u:Id="uuid-e2d08122-45ab-45cd-80d1-46de2306836b-1" Type="http://schemas.xmlsoap.org/ws/2005/02/trust/Nonce" …
Run Code Online (Sandbox Code Playgroud)

java wcf ws-security web-services cxf

6
推荐指数
1
解决办法
1437
查看次数

标签 统计

cxf ×2

java ×2

interceptor ×1

outputstream ×1

wcf ×1

web-services ×1

ws-security ×1