gpt4 book ai didi

web-services - SOAPMessageContext.getMessage() 在 WAS 7 上的协议(protocol)处理程序中不起作用

转载 作者:行者123 更新时间:2023-12-02 21:57:44 24 4
gpt4 key购买 nike

我在 RAD 8 和 Websphere v7 上使用 JAX-WS 创建了 Web 服务。我使用 ProtocolHandler 制作了处理程序来操作 SOAP 消息。

在handleMessage(SOAPMessageContext)方法中,我调用了getMessage()来获取SOAP消息。我不能。这是我的代码

public boolean handleMessage(SOAPMessageContext context) {
try {
SOAPMessage soapMessage = context.getMessage(); // getMessage() always cause the error
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope soapEnvelope= soapPart.getEnvelope();

} catch (SOAPException e) {
System.out.println("SOAPException");
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return true;
}

我总是收到以下错误。看来这个问题与SAAJ库有关。但据我所知,我不明白IBM JDK有SAAJ实现的类。而且......上面的代码两天前就有效了。之后就不行了。

所以我删除了所有项目文件并创建新的动态 Web 项目来检查它是否有效。这不起作用...

有人知道解决办法吗?或者有同样的问题?

[13. 7. 4   21:16:41:028 KST] 0000001c SystemErr     R javax.xml.ws.WebServiceException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
[13. 7. 4 21:16:41:028 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
[13. 7. 4 21:16:41:028 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.message.impl.MessageImpl.getAsSOAPMessage(MessageImpl.java:344)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.handler.SoapMessageContext.getMessage(SoapMessageContext.java:183)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at com.koreanair.naora.xml.handler.RAAWPID01ServicesProtocolHandler.handleMessage(RAAWPID01ServicesProtocolHandler.java:28)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at com.koreanair.naora.xml.handler.RAAWPID01ServicesProtocolHandler.handleMessage(RAAWPID01ServicesProtocolHandler.java:1)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.handler.HandlerChainProcessor.callHandleMessageWithTracker(HandlerChainProcessor.java:871)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.handler.HandlerChainProcessor.handleMessage(HandlerChainProcessor.java:516)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.handler.HandlerChainProcessor.callGenericHandlers(HandlerChainProcessor.java:289)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.handler.HandlerChainProcessor.processChain(HandlerChainProcessor.java:232)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.handler.HandlerInvokerUtils.invokeInboundHandlers(HandlerInvokerUtils.java:65)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.handler.impl.HandlerInvokerImpl.invokeInboundHandlers(HandlerInvokerImpl.java:37)
[13. 7. 4 21:16:41:029 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.server.EndpointController.inboundHeaderAndHandlerProcessing(EndpointController.java:348)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.server.EndpointController.handleRequest(EndpointController.java:260)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:103)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:161)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:189)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at com.ibm.ws.websvcs.transport.http.WASAxis2Servlet.doPost(WASAxis2Servlet.java:1442)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:944)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:507)
[13. 7. 4 21:16:41:030 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3954)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[13. 7. 4 21:16:41:031 KST] 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[13. 7. 4 21:16:41:056 KST] 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
[13. 7. 4 21:16:41:056 KST] 0000001c SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[13. 7. 4 21:16:41:056 KST] 0000001c SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[13. 7. 4 21:16:41:056 KST] 0000001c SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
[13. 7. 4 21:16:41:056 KST] 0000001c SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1656)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.sun.xml.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:536)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:316)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:74)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at org.apache.axis2.jaxws.message.impl.MessageImpl.getAsSOAPMessage(MessageImpl.java:285)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R ... 41 more
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R Caused by: java.lang.NoClassDefFoundError: com/sun/xml/messaging/saaj/soap/SOAPDocumentImpl
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.<init>(SOAPPartImpl.java:106)
[13. 7. 4 21:16:41:057 KST] 0000001c SystemErr R at com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.getSOAPPart(Message1_1Impl.java:90)
[13. 7. 4 21:16:41:058 KST] 0000001c SystemErr R at com.sun.xml.messaging.saaj.soap.MessageImpl.initCharsetProperty(MessageImpl.java:1441)
[13. 7. 4 21:16:41:058 KST] 0000001c SystemErr R at com.sun.xml.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:406)
[13. 7. 4 21:16:41:058 KST] 0000001c SystemErr R ... 44 more

最佳答案

您可以使用 SOAP Handler 拦截 SOAP 传入或传出 header 。使用注释引用 WS 类/委托(delegate)调用中的句柄,并在 Handler 类中覆盖 handleRequest()。

例如:

Handler.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<javaee:handler-chains
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<javaee:handler-chain>
<javaee:handler>
<javaee:handler-class>com.test.SoapHeaderValidation</javaee:handler-class>
</javaee:handler>
</javaee:handler-chain>
</javaee:handler-chains>

Delegete Class:

@HandlerChain(file="handler.xml")
public class RequestHandlerDelegate {

RequestHandler _requestHandler = new RequestHandler();

public String sendRequest(String xmlString) {
return _requestHandler.sendRequest(xmlString);
}

}

Handler Class:

public boolean handleMessage(SOAPMessageContext context) {

Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
// for response message only, true for outbound messages, false for inbound
if (!isRequest) {
try {
SOAPMessage soapMsg = context.getMessage();
SOAPEnvelope envelope= soapMsg.getSOAPPart().getEnvelope();
SOAPHeader header = envelope.getHeader();

if (header == null) {
generateSOAPErrMessage(soapMsg, "NO SOAP Header");
}
NodeList nl = header.getElementsByTagName("wsse:UsernameToken");
String user = nl.item(0).getFirstChild().getFirstChild().getNodeValue();
String password = nl.item(0).getFirstChild().getNextSibling().getFirstChild().getNodeValue();

} catch (Excection e) {
System.Out.println(e);
}

关于web-services - SOAPMessageContext.getMessage() 在 WAS 7 上的协议(protocol)处理程序中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17470307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com