當前位置: 首頁>>代碼示例>>Java>>正文


Java SoapVersionFactory類代碼示例

本文整理匯總了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;
            }
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:33,代碼來源:SoapMessageHeaderFilter.java

示例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();
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:49,代碼來源:MediatorInInterceptor.java


注:本文中的org.apache.cxf.binding.soap.SoapVersionFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。