use of org.apache.cxf.binding.soap.SoapVersion in project steve by RWTH-i5-IDSG.
the class MediatorInInterceptor method handleMessage.
public final void handleMessage(SoapMessage message) {
String schemaNamespace = "";
InterceptorChain chain = message.getInterceptorChain();
// Scan the incoming message for its schema namespace
try {
// Create a buffered stream so that we get back the original stream after scanning
InputStream is = message.getContent(InputStream.class);
BufferedInputStream bis = new BufferedInputStream(is);
bis.mark(bis.available());
message.setContent(InputStream.class, bis);
String encoding = (String) message.get(Message.ENCODING);
XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(bis, encoding);
DepthXMLStreamReader xmlReader = new DepthXMLStreamReader(reader);
if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
String ns = xmlReader.getNamespaceURI();
SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
// Advance just past header
StaxUtils.toNextTag(xmlReader, soapVersion.getBody());
// Past body
xmlReader.nextTag();
}
schemaNamespace = xmlReader.getName().getNamespaceURI();
bis.reset();
} catch (IOException | XMLStreamException ex) {
log.error("Exception happened", ex);
}
// We redirect the message to the actual OCPP service
Server targetServer = actualServers.get(schemaNamespace);
// Redirect the request
if (targetServer != null) {
MessageObserver mo = targetServer.getDestination().getMessageObserver();
mo.onMessage(message);
}
// Now the response has been put in the message, abort the chain
chain.abort();
}
Aggregations