Hi Guys,
In setPayload(Source s) method of
org.apache.cxf.jaxws.handler.logical.LogicalMessageImpl.java,
we will set SOAPMessage directly in Inbound as below:
SOAPMessage m = message.getContent(SOAPMessage.class);
if (m != null && !MessageUtils.isOutbound(message)) {
try {
SAAJUtils.getBody(m).removeContents();
W3CDOMStreamWriter writer = new
W3CDOMStreamWriter(SAAJUtils.getBody(m));
StaxUtils.copy(s, writer);
writer.flush();
writer.close();
if (mode == Service.Mode.MESSAGE) {
s = new DOMSource(m.getSOAPPart());
} else {
s = new DOMSource(SAAJUtils.getBody(m).getFirstChild());
}
W3CDOMStreamReader r = new
W3CDOMStreamReader(DOMUtils.getFirstChildElement(SAAJUtils.getBody(m)));
message.setContent(XMLStreamReader.class, r);
} catch (Exception e) {
throw new Fault(e);
}
}
I have a question here why we do not use the same logic in Outbound?
I noticed we have one LogicalHandlerOutEndingInterceptor. We set SOAPMessage
in the handleMessage()method of this class.
Can we use the same method with Inbound? We may need to modify
handleMessage() method of LogicalHandlerOutEndingInterceptor:
origMessage = message.getContent(SOAPMessage.class);
if (origMessage != null) {
message.setContent(SOAPMessage.class, origMessage);
} else {
try {
reader = message.getContent(XMLStreamReader.class);
message.removeContent(XMLStreamReader.class);
if (reader != null) {
StaxUtils.copy(reader, origWriter);
} else if (domWriter.getDocument().getDocumentElement() !=
null) {
StaxUtils.copy(domWriter.getDocument(), origWriter);
}
message.setContent(XMLStreamWriter.class, origWriter);
} catch (XMLStreamException e) {
throw new Fault(e);
}
}
--
View this message in context:
http://cxf.547215.n5.nabble.com/Why-only-modify-SOAPMessage-in-Inbound-when-setPayload-in-JAXWS-logicalHandler-tp5738291.html
Sent from the cxf-dev mailing list archive at Nabble.com.