我正在使用.net开发的Web服务,它接受用户名和密码作为SOAP标头的一部分。我创建了SOAPHandler来创建标题。
我打印了如下信息:
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>xxxxxxxxxxx</wsse:Username>
<wsse:Password>xxxxxxxx</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
当我点击服务时,我收到以下错误。
[4/3/16 18:53:10:342 EET] 00000027 SystemErr R javax.xml.ws.WebServiceException: org.apache.axis2.AxisFault: Must
> Understand check failed for header
> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
> : Security
> [4/3/16 18:53:10:343 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
> [4/3/16 18:53:10:343 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
> [4/3/16 18:53:10:343 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
> [4/3/16 18:53:10:343 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:586)
> [4/3/16 18:53:10:343 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:130)
> [4/3/16 18:53:10:344 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:93)
> [4/3/16 18:53:10:344 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:391)
> [4/3/16 18:53:10:344 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:208)
> [4/3/16 18:53:10:344 EET] 00000027 SystemErr R at com.sun.proxy.$Proxy37.authenticateSP(Unknown Source)
> [4/3/16 18:53:10:344 EET] 00000027 SystemErr R at com.id3global.id3gws._2013._04.IGlobalAuthenticate_BasicHttpBindingGlobalAuthenticate_Client.main(IGlobalAuthenticate_BasicHttpBindingGlobalAuthenticate_Client.java:90)
> [4/3/16 18:53:10:345 EET] 00000027 SystemErr R at com.eeft.ws.ppd.EwalletBalanceInquiryWSBeanPortBindingImpl.ewalletBalanceInquiry(EwalletBalanceInquiryWSBeanPortBindingImpl.java:104)
> [4/3/16 18:53:10:345 EET] 00000027 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [4/3/16 18:53:10:345 EET] 00000027 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
> [4/3/16 18:53:10:345 EET] 00000027 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
> [4/3/16 18:53:10:345 EET] 00000027 SystemErr R at java.lang.reflect.Method.invoke(Method.java:611)
> [4/3/16 18:53:10:345 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeMethod(JavaDispatcher.java:203)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeOperation(JavaDispatcher.java:158)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processRequestResponse(SoapRPCProcessor.java:490)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processMessage(SoapRPCProcessor.java:433)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.BasicDispatcher.processMessage(BasicDispatcher.java:134)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:204)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:153)
> [4/3/16 18:53:10:346 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:336)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:1246)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:344)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
> [4/3/16 18:53:10:347 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1700)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:970)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:508)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3994)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
> [4/3/16 18:53:10:348 EET] 00000027 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:516)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:307)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:278)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
> [4/3/16 18:53:10:349 EET] 00000027 SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
> [4/3/16 18:53:10:350 EET] 00000027 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
> [4/3/16 18:53:10:350 EET] 00000027 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
> [4/3/16 18:53:10:350 EET] 00000027 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
> [4/3/16 18:53:10:350 EET] 00000027 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
> [4/3/16 18:53:10:350 EET] 00000027 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1662)
> [4/3/16 18:53:10:350 EET] 00000027 SystemErr R Caused by: org.apache.axis2.AxisFault: Must Understand check failed for header
> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
> : Security
> [4/3/16 18:53:10:350 EET] 00000027 SystemErr R at org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:127)
> [4/3/16 18:53:10:351 EET] 00000027 SystemErr R at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:191)
> [4/3/16 18:53:10:351 EET] 00000027 SystemErr R at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:363)
> [4/3/16 18:53:10:351 EET] 00000027 SystemErr R at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
> [4/3/16 18:53:10:351 EET] 00000027 SystemErr R at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
> [4/3/16 18:53:10:351 EET] 00000027 SystemErr R at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
> [4/3/16 18:53:10:351 EET] 00000027 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:581)
> [4/3/16 18:53:10:351 EET] 00000027 SystemErr R ... 50 more
我删除了mustunderstand标记并将值更改为零仍然是相同的错误。
答案 0 :(得分:2)
我错过了覆盖处理程序中的getHeaders()
方法。下面的帖子帮助我添加了它开始工作的处理程序。
@Override
public Set<QName> getHeaders() {
QName securityHeader = new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
"Security");
HashSet<QName> headers = new HashSet<QName>();
headers.add(securityHeader);
return headers;
}