我必须在 Java 4 中编写一个 JAX-RPC SOAP 消息处理程序,并且我需要在消息中添加一个安全标头。
目前,当我尝试发送消息时出现java.lang.AbstractMethodError: org.apache.axis.message.SOAPHeader.addHeaderElement(Ljavax/xml/namespace/QName;)Ljavax/xml/soap/SOAPHeaderElement;
错误。
我在网上找不到太多关于这个错误的信息,所以任何帮助都将不胜感激!
我的代码如下:
public final boolean handleRequest(MessageContext context) {
SOAPMessageContext soapContext = (SOAPMessageContext) context;
String authId = "test";
try {
SOAPMessage soapMsg = soapContext.getMessage();
SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnv.getHeader();
/* If no header, add one */
if (soapHeader == null) {
soapHeader = soapEnv.addHeader();
}
/* Add a soap header, name as AUTH_ID_KEY */
QName qname = new QName(TARGET_NAMESPACE, AUTH_ID_KEY);
SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(qname);
soapHeaderElement.addTextNode(authId);
soapMsg.saveChanges();
} catch (SOAPException e) {
throw new ProtocolException(e);
}
return true;
}
感谢您的任何帮助!