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


Java StAXSOAPModelBuilder.getDocumentElement方法代码示例

本文整理汇总了Java中org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getDocumentElement方法的典型用法代码示例。如果您正苦于以下问题:Java StAXSOAPModelBuilder.getDocumentElement方法的具体用法?Java StAXSOAPModelBuilder.getDocumentElement怎么用?Java StAXSOAPModelBuilder.getDocumentElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder的用法示例。


在下文中一共展示了StAXSOAPModelBuilder.getDocumentElement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createXMLFault

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public static XMLFault createXMLFault(Block b, Protocol p) {
    // Because of the requirement that we have a full SOAP envelope structure as
    // the input to the StAXSOAPModelBuilder, we have to have a dummy envelope
    // that wraps our fault.  This will allow the Axiom SOAPFault object to
    // be created.        
    Message m = null;
    try {
        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
        m = mf.create(p);
        m.setBodyBlock(b);
    } catch (XMLStreamException e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
    
    SOAPEnvelope dummyEnv = (SOAPEnvelope) m.getAsOMElement();        
    
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(dummyEnv.getXMLStreamReaderWithoutCaching());
    SOAPEnvelope newEnv = (SOAPEnvelope) builder.getDocumentElement();
    
    SOAPBody body = newEnv.getBody();
    SOAPFault fault = body.getFault();
    
    Block[] details = getDetailBlocks(fault);
    
    return XMLFaultUtils.createXMLFault(fault, details);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:XMLFaultUtils.java

示例2: testOMElementDispatchMessageMode

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
/**
 * Test sending a SOAP 1.2 request in MESSAGE mode
 */
public void testOMElementDispatchMessageMode() throws Exception {
    // Create the JAX-WS client needed to send the request
    Service service = Service.create(serviceName);
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
    Dispatch<OMElement> dispatch = service.createDispatch(
            portName, OMElement.class, Mode.MESSAGE);
    
    // Create the OMElement object with the payload contents.  Since
    // we're in PAYLOAD mode, we don't have to worry about the envelope.
    StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+request+SOAP11_ENVELOPE_TAIL);
    XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
    SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();

    
    OMElement response = dispatch.invoke(om);
    
    
    String responseText = response.toStringWithConsume();
    assertTrue(responseText.contains("soap"));
    assertTrue(responseText.contains("Body"));
    assertTrue(responseText.contains("Envelope"));
    assertTrue(responseText.contains("Hello Dispatch OM"));
    
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:29,代码来源:OMProviderTests.java

示例3: testOMElementDispatchMessageModeSOAPFaultException

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
/**
 * Test sending a SOAP 1.2 request in MESSAGE mode
 */
public void testOMElementDispatchMessageModeSOAPFaultException() throws Exception {
    // Create the JAX-WS client needed to send the request
    Service service = Service.create(serviceName);
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
    Dispatch<OMElement> dispatch = service.createDispatch(
            portName, OMElement.class, Mode.MESSAGE);
    
    StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+SOAPFaultRequest+SOAP11_ENVELOPE_TAIL);
    XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
    SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
    OMElement response = null;
    try{
    	response = dispatch.invoke(om);
    	String responseText = response.toStringWithConsume();
    }catch(Exception e){
    	assertTrue(e instanceof SOAPFaultException);
    }
    assertTrue(response ==null);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:OMProviderTests.java

示例4: testOMElementDispatchMessageModeSOAPFault

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void testOMElementDispatchMessageModeSOAPFault() throws Exception {
    // Create the JAX-WS client needed to send the request
    Service service = Service.create(serviceName);
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
    Dispatch<OMElement> dispatch = service.createDispatch(
            portName, OMElement.class, Mode.MESSAGE);
    BindingProvider bp = (BindingProvider)dispatch;
    bp.getRequestContext().put(Constants.THROW_EXCEPTION_IF_SOAP_FAULT, Boolean.FALSE);
   
    StringReader sr = new StringReader(SOAP11_ENVELOPE_HEAD+SOAPFaultRequest+SOAP11_ENVELOPE_TAIL);
    XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
    SOAPEnvelope om = (SOAPEnvelope) builder.getDocumentElement();
    OMElement response = null;
    try{
    	response = dispatch.invoke(om);
    	String responseText = response.toStringWithConsume();
    }catch(Exception e){
    	fail();
    }
    assertTrue(response !=null);
    assertTrue(response instanceof OMElement);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:OMProviderTests.java

示例5: invoke

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public OMElement invoke(OMElement om) throws SOAPFaultException{
    try{
        StringReader sr = null;
       if(om!=null){
         String requestText = om.toStringWithConsume();
         if(requestText.contains("SOAPFault")){
        	 throwSOAPFaultException();
         }
         if((requestText.contains("Hello Provider OM"))){
             sr = new StringReader(SOAP11_ENVELOPE_HEAD+response+SOAP11_ENVELOPE_TAIL);
         }
         if((!requestText.contains("Hello Provider OM"))){
             sr = new StringReader(SOAP11_ENVELOPE_HEAD+"ack:received OM"+SOAP11_ENVELOPE_TAIL);
         }
       }else{
           sr = new StringReader(SOAP11_ENVELOPE_HEAD+"null request"+SOAP11_ENVELOPE_TAIL);
       }
        XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
        SOAPEnvelope responseOM = (SOAPEnvelope) builder.getDocumentElement();

        return responseOM;
    }catch(Exception e){
        throw new WebServiceException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:OMProvider.java

示例6: parseOrder

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
/**
 * @param payload XML message content came inside the JMS message
 * @throws XMLStreamException on error
 */
private void parseOrder(String payload) throws XMLStreamException {
    InputStream is = new ByteArrayInputStream(payload.getBytes());
    javax.xml.stream.XMLStreamReader parser = XMLInputFactory
            .newInstance().createXMLStreamReader(is);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser,
            null);
    SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
    // retrieve SOAP body
    SOAPBody soapBody = envelope.getBody();
    OMElement messageNode = soapBody.getFirstChildWithName(new QName(
            FIX_MSG));
    Iterator<?> messageElements = (Iterator<?>) messageNode
            .getChildElements();
    while (messageElements.hasNext()) {
        OMElement node = (OMElement) messageElements.next();
        if (node.getQName().getLocalPart().equals(FIX_MSG_BODY)) {
            Iterator<?> bodyElements = (Iterator<?>) node.getChildElements();
            while (bodyElements.hasNext()) {
                OMElement bodyNode = (OMElement) bodyElements.next();
                String tag = bodyNode
                        .getAttributeValue(new QName(FIX_MSG_ID));
                String value = bodyNode.getText();
                if (tag.equals(FIX_MSG_SYMBOL)) {
                    inSymbol = value;
                } else if (tag.equals(FIX_MSG_CLORDID)) {
                    inClOrderID = value;
                } else if (tag.equals(FIX_MSG_ORDQTY)) {
                    inQty = value;
                }
            }
        }
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:38,代码来源:AMQPConsumer.java

示例7: testOMElementDispatchWithParsedEntityReader

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
/**
 * Test sending a SOAP 1.2 request in MESSAGE mode with
 * a Parser that can provide the InputStream for the payload
 */
public void testOMElementDispatchWithParsedEntityReader() throws Exception {
    
    // Subsitute a ParsedEntityReader that will provide the
    // payload InputStream.  This simulates parsers that provide this
    // feature.
    ParsedEntityReaderFactory factory = (ParsedEntityReaderFactory)
    FactoryRegistry.getFactory(ParsedEntityReaderFactory.class);
    ParsedEntityReader per = new ParsedEntityReaderTest();
    factory.setParsetEntityReader(per);
    
    try {
        // Create the JAX-WS client needed to send the request
        Service service = Service.create(QNAME_SERVICE);
        service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
        Dispatch<OMElement> dispatch = service.createDispatch(
                QNAME_PORT, OMElement.class, Mode.MESSAGE);

        // Create the OMElement object with the payload contents.  Since
        // we're in PAYLOAD mode, we don't have to worry about the envelope.
        StringReader sr = new StringReader(sampleEnvelope);
        XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inputReader, null); 
        SOAPEnvelope soap12Envelope = (SOAPEnvelope) builder.getDocumentElement();


        // Invoke
        OMElement response = dispatch.invoke(soap12Envelope);
        

        SOAPEnvelope responseEnv = (SOAPEnvelope) response;
        SOAPBody responseBody = responseEnv.getBody();
        OMElement payload = responseBody.getFirstElement();

        // At this point, the payload should be an OMSourcedElement
        // that was created from the ParsedEntityReader's stream
        assertTrue(payload instanceof OMSourcedElement);


        // Check to make sure the contents of the message are correct
        String responseText = payload.toStringWithConsume();
        assertTrue(responseText.contains("TEST RESPONSE"));
    } finally {
        
        // Uninstall the Test ParsedEntityReader
        factory.setParsetEntityReader(null);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:52,代码来源:OMElementDispatchTest.java


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