<soapenv:Envelope>
<soapenv:Header>
<cor:india>test</cor:india>
</soapenv:Header>
<soapenv:Body>
.
.
</soapenv:Body>
</soapenv:Envelope>
OMFactory omFactory =OMAbstractFactory.getOMFactory();
OMNamespace omNamespace = omFactory.createOMNamespace("http://example.com/...", "cor");
OMElement header = omFactory.createOMElement("india", omNamespace);
header.setText("test");
stub._getServiceClient().addHeader(header);
我想将自定义标头添加到使用轴 2 和壁垒的肥皂请求中。但下面是我得到的例外
Caused by: org.apache.rampart.RampartException: Error in extracting message properties
at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:379)
at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:61)
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:65)
... 10 more
Caused by: org.apache.ws.security.WSSecurityException: Error in converting SOAP Envelope to Document; nested exception is:
java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl cannot be cast to org.apache.axiom.soap.SOAPHeaderBlock
at org.apache.rampart.util.Axis2Util.getDocumentFromSOAPEnvelope(Axis2Util.java:191)
at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:270)
... 12 more
Caused by: java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl cannot be cast to org.apache.axiom.soap.SOAPHeaderBlock
at org.apache.rampart.util.Axis2Util.getDocumentFromSOAPEnvelope(Axis2Util.java:141)
... 13 more