本文整理匯總了Java中org.apache.cxf.binding.soap.SoapVersionFactory類的典型用法代碼示例。如果您正苦於以下問題:Java SoapVersionFactory類的具體用法?Java SoapVersionFactory怎麽用?Java SoapVersionFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SoapVersionFactory類屬於org.apache.cxf.binding.soap包,在下文中一共展示了SoapVersionFactory類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filter
import org.apache.cxf.binding.soap.SoapVersionFactory; //導入依賴的package包/類
public void filter(Direction direction, List<Header> headers) {
// Treat both in and out direction the same
if (headers == null) {
return;
}
Iterator<Header> iterator = headers.iterator();
while (iterator.hasNext()) {
Header header = iterator.next();
LOG.trace("Processing header: {}", header);
if (!(header instanceof SoapHeader)) {
LOG.trace("Skipped header: {} since it is not a SoapHeader", header);
continue;
}
SoapHeader soapHeader = SoapHeader.class.cast(header);
for (Iterator<SoapVersion> itv = SoapVersionFactory.getInstance().getVersions(); itv.hasNext();) {
SoapVersion version = itv.next();
if (soapHeader.getActor() != null
&& soapHeader.getActor().equals(version.getNextRole())) {
// dropping headers if actor/role equals to {ns}/role|actor/next
// cxf SoapHeader needs to have soap:[email protected] attribute,
// then we can check for it here as well
LOG.trace("Filtered header: {}", header);
iterator.remove();
break;
}
}
}
}
示例2: handleMessage
import org.apache.cxf.binding.soap.SoapVersionFactory; //導入依賴的package包/類
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);
}
// Init the lookup, when the first message ever arrives
if (actualServers.isEmpty()) {
initServerLookupMap(message);
}
// 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();
}