Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将SecurityContextToken设置为SOAP头_Java_Web Services_Jax Ws_Cxf_Soap Client - Fatal编程技术网

Java 将SecurityContextToken设置为SOAP头

Java 将SecurityContextToken设置为SOAP头,java,web-services,jax-ws,cxf,soap-client,Java,Web Services,Jax Ws,Cxf,Soap Client,我使用wsimport构建java类。在第一个soap请求中,我得到一个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/200

我使用wsimport构建java类。在第一个soap请求中,我得到一个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)