当前位置: 首页>>代码示例>>Java>>正文


Java OMSourcedElementImpl类代码示例

本文整理汇总了Java中org.apache.axiom.om.impl.llom.OMSourcedElementImpl的典型用法代码示例。如果您正苦于以下问题:Java OMSourcedElementImpl类的具体用法?Java OMSourcedElementImpl怎么用?Java OMSourcedElementImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OMSourcedElementImpl类属于org.apache.axiom.om.impl.llom包,在下文中一共展示了OMSourcedElementImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processDocument

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
public OMElement processDocument(InputStream inputStream,
                                 String contentType,
                                 MessageContext msgContext) throws AxisFault {

    OMFactory factory = OMAbstractFactory.getOMFactory();
    String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
    QName wrapperQName = getWrapperQName(msgContext);
    Reader reader;
    try {
        reader = new InputStreamReader(inputStream, charSetEnc);
    } catch (UnsupportedEncodingException ex) {
        throw new AxisFault("Unsupported encoding: " + charSetEnc, ex);
    }
    return new OMSourcedElementImpl(wrapperQName, factory,
            new WrappedTextNodeOMDataSourceFromReader(wrapperQName, reader));
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:17,代码来源:PlainTextBuilder.java

示例2: getOutputOMElement

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
public OMElement getOutputOMElement(final Object returnObject,
                                    final Operation operation,
                                    final JavaObjectSerializer javaObjectSerializer,
                                    SOAPFactory soapFactory) {
    OMDataSource omDataSource = new RMIDataSource() {

        public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException {
            try {
                javaObjectSerializer.serializeOutputElement(returnObject,
                        operation.getOutPutElement(),
                        operation.getOutputParameter(),
                        xmlWriter);
            } catch (XmlSerializingException e) {
                new XMLStreamException("Problem in serializing the return object", e);
            }
        }
    };
    XmlElement outXmlElement = operation.getOutPutElement();
    QName outElementQName = new QName(outXmlElement.getNamespace(), outXmlElement.getName());
    return new OMSourcedElementImpl(outElementQName, soapFactory, omDataSource);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:RMIMessageReciever.java

示例3: getParameterOMElement

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
public OMElement getParameterOMElement(final Object exceptionObject,
                                       final Parameter parameter,
                                       final JavaObjectSerializer javaObjectSerializer,
                                       SOAPFactory soapFactory){
    OMDataSource omDataSource = new RMIDataSource(){

        public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException {
            try {
                javaObjectSerializer.serializeParameter(exceptionObject,parameter,xmlWriter, new NamespacePrefix());
            } catch (XmlSerializingException e) {
                throw new XMLStreamException("problem in serializing the exception object ",e);
            }
        }
    };
    XmlElement exceptionElement = parameter.getElement();
    QName outElementQName = new QName(exceptionElement.getNamespace(), exceptionElement.getName());
    OMElement omElement = new OMSourcedElementImpl(outElementQName, soapFactory, omDataSource);
    return omElement;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:20,代码来源:RMIMessageReciever.java

示例4: getInputOMElement

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
private OMElement getInputOMElement(final Object[] inputObjects,
                                    final Operation operation,
                                    final JavaObjectSerializer javaObjectSerializer,
                                    OMFactory omFactory) {
    OMDataSource omDataSource = new RMIDataSource() {

        public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException {
            try {
                javaObjectSerializer.serializeInputElement(inputObjects,
                        operation.getInputElement(),
                        operation.getInputParameters(),
                        xmlWriter);
            } catch (XmlSerializingException e) {
                new XMLStreamException("Problem in serializing the return object", e);
            }
        }
    };
    XmlElement inputXmlElement = operation.getInputElement();
    QName inputElementQName = new QName(inputXmlElement.getNamespace(), inputXmlElement.getName());
    return new OMSourcedElementImpl(inputElementQName, omFactory, omDataSource);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:RMIClient.java

示例5: dispatch

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
/**
 * Dispatches the current request. This method does common dispatching logic and call the 
 * request type specific {@link DataServiceRequest}{@link #processRequest()} method.
 * @return The result of the request invocation
 * @throws DataServiceFault
 */
public OMElement dispatch() throws DataServiceFault {
	/* set user */
	if (this.getUserRoles() != null) {
		DataServiceUser currentUser = new DataServiceUser(this.getUser(),
				new HashSet<String>(Arrays.asList(this.getUserRoles())));
		DataService.setCurrentUser(currentUser);
	}		
	
	/* request specific processing */
	OMElement result = this.processRequest();
	/* check disable streaming */
	if (this.isDisableStreaming()) {
		/* if result is of type OMSourcedElementImpl, that means,
		 * it is still in streaming mode, result.isComplete does not work */
		if (result instanceof OMSourcedElementImpl) {
			result = DBUtils.cloneAndReturnBuiltElement(result);
		}
	}
	return result;
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:27,代码来源:DataServiceRequest.java

示例6: processSingleRequest

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
private OMElement processSingleRequest() throws DataServiceFault {
	DataService dataService = this.getDataService();
	String requestName = this.getRequestName();
	/* set the operation name to invoke and the parameters */
	DSOMDataSource ds = new DSOMDataSource(dataService, requestName, this.getParams());

	/* check if the current request has a result, if so, return the OMElement */
	if (dataService.hasResultForRequest(this.getRequestName())) {
		String resultWrapper = dataService.getResultWrapperForRequest(requestName);
		String ns = dataService.getNamespaceForRequest(requestName);
		return new OMSourcedElementImpl(new QName(ns,
				resultWrapper), DBUtils.getOMFactory(), ds);
	} else { /* if no response i.e. in-only, execute the request now */
		try {
			ds.executeInOnly();
		} catch (XMLStreamException e) {
			throw new DataServiceFault(e, "Error in DS non result invoke.");
		}
		return null;
	}
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:22,代码来源:SingleDataServiceRequest.java

示例7: testJAXBOutflowPerf

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
/**
 * Create a JAXBBlock containing a JAX-B business object 
 * and simulate a normal Proxy output flow
 * @throws Exception
 */
public void testJAXBOutflowPerf() throws Exception {
    // Create a SOAP 1.1 Message
    MessageFactory mf = (MessageFactory)
        FactoryRegistry.getFactory(MessageFactory.class);
    Message m = mf.create(Protocol.soap11);
    
    // Indicate that the style is RPC, Indicate the Operation QName
    m.setStyle(Style.RPC);
    QName opQName = new QName("urn://sample", "op", "m");
    m.setOperationElement(opQName);
    
    // Get the BlockFactory
    JAXBBlockFactory bf = (JAXBBlockFactory)
        FactoryRegistry.getFactory(JAXBBlockFactory.class);
    
    // Create the JAXBContext
    JAXBBlockContext context = new JAXBBlockContext(StockPrice.class.getPackage().getName());
    
    // Create the JAX-B object
    ObjectFactory of = new ObjectFactory();
    StockPrice obj = of.createStockPrice();
    obj.setPrice("100");
    
    // Create the JAX-B Element
    QName paramQName = new QName("urn://sample", "param", "m");
    JAXBElement e = new JAXBElement(paramQName, StockPrice.class, obj);
    
    // Create a JAXBBlock using the param object as the content.  This simulates
    // what occurs on the outbound JAX-WS Proxy client
    Block block = bf.createFrom(e, context, null);
    
    // Add the block to the message as normal body content.
    m.setBodyBlock(block);
    
    // Check to see if the message is a fault.  The client/server will always call this method.
    // The Message must respond appropriately without doing a conversion.
    boolean isFault = m.isFault();
    assertTrue(!isFault);
    assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
                "SPINE".equals(m.getXMLPartContentType()));
    
    // On an outbound flow, we need to convert the Message 
    // to an OMElement, specifically an OM SOAPEnvelope, 
    // so we can set it on the Axis2 MessageContext
    org.apache.axiom.soap.SOAPEnvelope env = 
        (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
    
    // Check to see if the message is a fault.  The client/server will always call this method.
    // The Message must respond appropriately without doing a conversion.
    isFault = m.isFault();
    assertTrue(!isFault);
    assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
                "OM".equals(m.getXMLPartContentType()));
    
    // PERFORMANCE CHECK:
    // The param in the body should be an OMSourcedElement
    OMElement o = env.getBody().getFirstElement().getFirstElement();
    assertTrue(o instanceof OMSourcedElementImpl);
    assertTrue(((OMSourcedElementImpl)o).isExpanded() == false);
    
    // Serialize the Envelope using the same mechanism as the 
    // HTTP client.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    env.serializeAndConsume(baos, new OMOutputFormat());
    
    // To check that the output is correct, get the String contents of the 
    // reader
    String newText = baos.toString();
    TestLogger.logger.debug(newText);
    assertTrue(newText.contains("m:op"));
    assertTrue(newText.contains("m:param"));
    assertTrue(newText.contains("100"));
    assertTrue(newText.contains("Envelope"));
    assertTrue(newText.contains("Body"));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:81,代码来源:MessageRPCTests.java

示例8: testStringOutflow

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
/**
 * Create a Block representing an XMLString and simulate a normal Dispatch<String> flow. In
 * addition the test makes sure that the XMLString block is not expanded during this process.
 * (Expanding the block degrades performance).
 * 
 * @throws Exception
 */
public void testStringOutflow() throws Exception {

    // Create a SOAP 1.1 Message
    MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
    Message m = mf.create(Protocol.soap11);

    // Get the BlockFactory
    XMLStringBlockFactory f =
            (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);

    // Create a Block using the sample string as the content. This simulates
    // what occurs on the outbound JAX-WS dispatch<String> client
    Block block = f.createFrom(sampleText, null, null);

    // Add the block to the message as normal body content.
    m.setBodyBlock(block);

    // Check to see if the message is a fault. The client/server will always call this method.
    // The Message must respond appropriately without doing a conversion.
    boolean isFault = m.isFault();
    assertTrue(!isFault);
    assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
               "SPINE".equals(m.getXMLPartContentType()));

    // On an outbound flow, we need to convert the Message
    // to an OMElement, specifically an OM SOAPEnvelope,
    // so we can set it on the Axis2 MessageContext
    org.apache.axiom.soap.SOAPEnvelope env =
            (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();

    // Check to see if the message is a fault. The client/server will always call this method.
    // The Message must respond appropriately without doing a conversion.
    isFault = m.isFault();
    assertTrue(!isFault);
    assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
               "OM".equals(m.getXMLPartContentType()));

    // PERFORMANCE CHECK:
    // The element in the body should be an OMSourcedElement
    OMElement o = env.getBody().getFirstElement();
    assertTrue(o instanceof OMSourcedElementImpl);
    assertTrue(((OMSourcedElementImpl) o).isExpanded() == false);

    // Serialize the Envelope using the same mechanism as the
    // HTTP client.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    env.serializeAndConsume(baos, new OMOutputFormat());

    String newText = baos.toString();
    TestLogger.logger.debug(newText);
    assertTrue(newText.contains(sampleText));
    assertTrue(newText.contains("soap"));
    assertTrue(newText.contains("Envelope"));
    assertTrue(newText.contains("Body"));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:63,代码来源:MessageTests.java

示例9: testJAXBOutflowPerf

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
/**
 * Same as JAXBOutputflow, but has an additional check
 * to make sure that the JAXB serialization is deferrred
 * until the actual serialization of the message.
 * @throws Exception
 */
public void testJAXBOutflowPerf() throws Exception {
    // Create a SOAP 1.1 Message
    MessageFactory mf = (MessageFactory)
        FactoryRegistry.getFactory(MessageFactory.class);
    Message m = mf.create(Protocol.soap11);
    
    // Get the BlockFactory
    JAXBBlockFactory bf = (JAXBBlockFactory)
        FactoryRegistry.getFactory(JAXBBlockFactory.class);
    
    // Create the JAX-B object
    ObjectFactory of = new ObjectFactory();
    EchoStringResponse obj = of.createEchoStringResponse();
    obj.setEchoStringReturn("sample return value");
    
    // Create the JAXBContext
    JAXBBlockContext context = 
        new JAXBBlockContext(EchoStringResponse.class.getPackage().getName());
   
    // Create a JAXBBlock using the Echo object as the content.  This simulates
    // what occurs on the outbound JAX-WS Dispatch<Object> client
    Block block = bf.createFrom(obj, context, null);
    
    // Add the block to the message as normal body content.
    m.setBodyBlock(block);
    
    // Check to see if the message is a fault.  The client/server will always call this method.
    // The Message must respond appropriately without doing a conversion.
    boolean isFault = m.isFault();
    assertTrue(!isFault);
    assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
                "SPINE".equals(m.getXMLPartContentType()));
    
    // On an outbound flow, we need to convert the Message 
    // to an OMElement, specifically an OM SOAPEnvelope, 
    // so we can set it on the Axis2 MessageContext
    org.apache.axiom.soap.SOAPEnvelope env = 
        (org.apache.axiom.soap.SOAPEnvelope) m.getAsOMElement();
    
    // Check to see if the message is a fault.  The client/server will always call this method.
    // The Message must respond appropriately without doing a conversion.
    isFault = m.isFault();
    assertTrue(!isFault);
    assertTrue("XMLPart Representation is " + m.getXMLPartContentType(),
                "OM".equals(m.getXMLPartContentType()));
    
    // PERFORMANCE CHECK:
    // The element in the body should be an OMSourcedElement
    OMElement o = env.getBody().getFirstElement();
    assertTrue(o instanceof OMSourcedElementImpl);
    assertTrue(((OMSourcedElementImpl)o).isExpanded() == false);
    
    // Serialize the Envelope using the same mechanism as the 
    // HTTP client.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    env.serializeAndConsume(baos, new OMOutputFormat());
    
    // To check that the output is correct, get the String contents of the 
    // reader
    String newText = baos.toString();
    TestLogger.logger.debug(newText);
    assertTrue(newText.contains(sampleJAXBText));
    assertTrue(newText.contains("soap"));
    assertTrue(newText.contains("Envelope"));
    assertTrue(newText.contains("Body"));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:73,代码来源:MessageTests.java

示例10: testAddRemoveAsOMElement

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
public void testAddRemoveAsOMElement() throws Exception {

		MessageContext messageContext = getMessageContext();
		
		SOAPHeadersAdapter.install(messageContext);
		
    	SOAPFactory sf = SOAPFactory.newInstance();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e1 = sf.createElement(ACOH1_HEADER_QNAME);
    	e1.addTextNode(CONTENT_STRING1);
    	String acoh1 = e1.toString();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e2 = sf.createElement(ACOH1_HEADER_QNAME);
    	e2.addTextNode(CONTENT_STRING2);
    	String acoh2 = e2.toString();

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
        
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
        
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        
        // get message object and convert to SOAPEnvelope
        OMElement omEnvelope = messageContext.getMessage().getAsOMElement();
        
        // confirm headers are there.  I can cast here only because I know the implementation.  :)
        SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next();

        Iterator<OMSourcedElementImpl> it = omHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        OMSourcedElementImpl headerElem1 = it.next();
        OMSourcedElementImpl headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
        
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
        
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
        
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detach();
        
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
        
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));

	}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:61,代码来源:SOAPHeadersAdapterTests.java

示例11: testAddRemoveAsOMElementUsingSourceFactory

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
public void testAddRemoveAsOMElementUsingSourceFactory() throws Exception {

		MessageContext messageContext = getMessageContextUsingSourceFactory();
		
		SOAPHeadersAdapter.install(messageContext);
		
    	SOAPFactory sf = SOAPFactory.newInstance();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e1 = sf.createElement(ACOH1_HEADER_QNAME);
    	e1.addTextNode(CONTENT_STRING1);
    	String acoh1 = e1.toString();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e2 = sf.createElement(ACOH1_HEADER_QNAME);
    	e2.addTextNode(CONTENT_STRING2);
    	String acoh2 = e2.toString();

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
        
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
        
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        
        // get message object and convert to SOAPEnvelope
        OMElement omEnvelope = messageContext.getMessage().getAsOMElement();
        
        // confirm headers are there.  I can cast here only because I know the implementation.  :)
        SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next();

        Iterator<OMSourcedElementImpl> it = omHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        OMSourcedElementImpl headerElem1 = it.next();
        OMSourcedElementImpl headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
        
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
        
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
        
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detach();
        
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
        
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));

	}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:61,代码来源:SOAPHeadersAdapterTests.java

示例12: testAddRemoveAsOMElementUsingSourceFactoryLogicalMessageImpl

import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; //导入依赖的package包/类
public void testAddRemoveAsOMElementUsingSourceFactoryLogicalMessageImpl() throws Exception {

		MessageContext messageContext = getMessageContextUsingSourceFactory();
		
		SOAPHeadersAdapter.install(messageContext);
		
    	SOAPFactory sf = SOAPFactory.newInstance();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e1 = sf.createElement(ACOH1_HEADER_QNAME);
    	e1.addTextNode(CONTENT_STRING1);
    	String acoh1 = e1.toString();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e2 = sf.createElement(ACOH1_HEADER_QNAME);
    	e2.addTextNode(CONTENT_STRING2);
    	String acoh2 = e2.toString();

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
        
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
        
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        
        List<String> headersList = adapter.get(ACOH1_HEADER_QNAME);
        headersList.get(0).toString();  // trigger some underlying OM implementation parsing
        
        // use the LogicalMessageImpl to get the message payload
        MyLogicalMessageImpl logicalMessageImpl = new MyLogicalMessageImpl(messageContext);
        Source payload = logicalMessageImpl.getPayload();
        payload.toString();
        
        // get message object and convert to SOAPEnvelope
        OMElement omEnvelope = messageContext.getMessage().getAsOMElement();
        
        // confirm headers are there.  I can cast here only because I know the implementation.  :)
        SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next();

        Iterator<OMSourcedElementImpl> it = omHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        OMSourcedElementImpl headerElem1 = it.next();
        OMSourcedElementImpl headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
        
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
        
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
        
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detach();
        
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
        
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));

	}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:69,代码来源:SOAPHeadersAdapterTests.java


注:本文中的org.apache.axiom.om.impl.llom.OMSourcedElementImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。