【问题标题】:Set SecurityContextToken to SOAP Header将 SecurityContextToken 设置为 SOAP 标头
【发布时间】:2014-02-21 15:22:09
【问题描述】:

我使用 wsimport 构建我的 java 类。在第一个肥皂请求中,我得到一个 SecurityToken。在其他请求中,我必须将此令牌放在标题中。我该怎么做?

我在网上找不到任何东西。

    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss wssecurity-secext-1.0.xsd" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc">
            <wsc:SecurityContextToken>
                    <wsc:Identifier>__TOKEN__</wsc:Identifier>
            </wsc:SecurityContextToken>
    </wsse:Security>

如果我通过示例设置标题。我得到以下异常。有什么想法吗?

SCHWERWIEGEND: SAAJ0120: Can't add a header when one is already present
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Can't add a header when one is    already present.
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.addHeader(EnvelopeImpl.java:114)
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.addHeader(EnvelopeImpl.java:94)
at client.header.WSSUsernameTokenSecurityHandler.handleMessage(WSSUsernameTokenSecurityHandler.java:47)
at client.header.WSSUsernameTokenSecurityHandler.handleMessage(WSSUsernameTokenSecurityHandler.java:15)
at org.apache.cxf.jaxws.handler.HandlerChainInvoker.invokeHandleMessage(HandlerChainInvoker.java:347)
at org.apache.cxf.jaxws.handler.HandlerChainInvoker.invokeHandlerChain(HandlerChainInvoker.java:254)
at org.apache.cxf.jaxws.handler.HandlerChainInvoker.invokeProtocolHandlers(HandlerChainInvoker.java:132)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessageInternal(SOAPHandlerInterceptor.java:169)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.access$000(SOAPHandlerInterceptor.java:71)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor$1.handleMessage(SOAPHandlerInterceptor.java:81)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor$1.handleMessage(SOAPHandlerInterceptor.java:78)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at $Proxy36.getWSR(Unknown Source)
at client.WSClient.main(WSClient.java:160)

【问题讨论】:

    标签: java web-services jax-ws cxf soap-client


    【解决方案1】:

    这取决于您在客户端使用的框架。一个如何做到这一点的例子可以在here找到。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多