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


Java StAXSOAPModelBuilder.getSOAPEnvelope方法代码示例

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


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

示例1: testConvertToDOOM

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void testConvertToDOOM() throws Exception {
    String xml = "<?xml version='1.0' encoding='utf-8'?>" +
            "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
            "<soapenv:Body><ns1:createAccountRequest xmlns:ns1=\"http://www.wso2.com/types\">" +
            "<clientinfo xmlns=\"http://www.wso2.com/types\"><name>bob</name><ssn>123456789</ssn></clientinfo>" +
            "<password xmlns=\"\">passwd</password></ns1:createAccountRequest></soapenv:Body></soapenv:Envelope>";

    StAXSOAPModelBuilder builder2 = new StAXSOAPModelBuilder(
            getTestEnvelope().getXMLStreamReader(),
            DOOMAbstractFactory.getSOAP11Factory(),
            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

    SOAPEnvelope envelope = builder2.getSOAPEnvelope();
    envelope.build();

    StringWriter writer = new StringWriter();
    envelope.serialize(writer);
    writer.flush();

    String s2 = writer.toString();

    assertXMLEqual(s2, xml);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:ADBSOAPModelBuilderTest.java

示例2: toOM

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
private org.apache.axiom.soap.SOAPEnvelope toOM(String xml)
        throws WebServiceException {
	if (log.isDebugEnabled()) {
	    log.debug("Converting SAAJ SOAPEnvelope String to an OM SOAPEnvelope");
	    log.debug("The conversion occurs due to " + JavaUtils.stackToString());
	} 
	
    XMLStreamReader reader;
    try {
        reader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xml.getBytes()));
    } catch (XMLStreamException e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
    // Get a SOAP OM Builder.  Passing null causes the version to be automatically triggered
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, null);
    // Create and return the OM Envelope
    return builder.getSOAPEnvelope();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:SAAJConverterImpl.java

示例3: buildSoapEnvelope

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
private static SOAPEnvelope buildSoapEnvelope() {

        String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">\n" +
                "    <soapenv:Body>\n" +
                "        <ns1:Project xmlns:ns1=\"http://axis2.apache.org/sample\">\n" +
                "            <ns1:Developer>\n" +
                "                <ns1:name>AAA</ns1:name>\n" +
                "                <ns1:location>Colombo</ns1:location>\n" +
                "            </ns1:Developer>\n" +
                "        </ns1:Project>\n" +
                "    </soapenv:Body>\n" +
                "</soapenv:Envelope>";

        SOAPEnvelope soapEnvelope = null;
        try {
            XMLStreamReader xmlStreamReader =
                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
            StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(xmlStreamReader);
            soapEnvelope = stAXSOAPModelBuilder.getSOAPEnvelope();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        }
        return soapEnvelope;
    }
 
开发者ID:syodage,项目名称:Axis2-Samples,代码行数:25,代码来源:SoapElementBuilder.java

示例4: testConvertToDOOM2

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void testConvertToDOOM2() throws Exception {
    String xml =
            "<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><ns1:createAccountRequest xmlns:ns1=\"http://www.wso2.com/types\"><ns1:clientinfo><name xmlns=\"\">bob</name><ssn xmlns=\"\">123456789</ssn></ns1:clientinfo><password xmlns=\"\">passwd</password></ns1:createAccountRequest></soapenv:Body></soapenv:Envelope>";

    CreateAccountRequest request = new CreateAccountRequest();
    ClientInfo clientInfo = new ClientInfo();
    clientInfo.setName("bob");
    clientInfo.setSsn("123456789");
    request.setClientInfo(clientInfo);
    request.setPassword("passwd");

    ADBSOAPModelBuilder builder = new ADBSOAPModelBuilder(request
            .getPullParser(CreateAccountRequest.MY_QNAME),
                                                          OMAbstractFactory.getSOAP11Factory());

    SOAPEnvelope env = builder.getEnvelope();

    StAXSOAPModelBuilder builder2 = new StAXSOAPModelBuilder(
            getTestEnvelope().getXMLStreamReaderWithoutCaching(),
            DOOMAbstractFactory.getSOAP11Factory(),
            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    SOAPEnvelope envelope = builder2.getSOAPEnvelope();
    envelope.build();

    StringWriter writer = new StringWriter();
    envelope.serialize(writer);
    writer.flush();

    XMLStreamReader r = StAXUtils.createXMLStreamReader(new StringReader(writer.toString()));
    PrintEvents.print(r);

    //TODO: FIXME. Simpler test in testPrintEvents2
    //assertXMLEqual(writer.toString(),xml);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:35,代码来源:ADBSOAPModelBuilderTest.java

示例5: createFrom

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public XMLPart createFrom(XMLStreamReader reader, Protocol protocol)
        throws XMLStreamException, WebServiceException {
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader,
                                                            null);  // Pass null has the version to trigger autodetection
    SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
    return createFrom(omEnvelope, protocol);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:8,代码来源:XMLPartFactoryImpl.java

示例6: testGetPayloadFromSoap12

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void testGetPayloadFromSoap12() throws Exception {
    // On inbound, there will already be an OM
    // which represents the message.  The following code simulates the input
    // OM
    StringReader sr = new StringReader(sampleSoap12Envelope);
    XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
    OMElement omElement = builder.getSOAPEnvelope();
    
    // The JAX-WS layer creates a Message from the OM
    MessageFactory mf = (MessageFactory)
        FactoryRegistry.getFactory(MessageFactory.class);
    Message m = mf.createFrom(omElement, null);
    
    // Make sure the right Protocol was set on the Message
    assertTrue(m.getProtocol().equals(Protocol.soap12));
    
    // Check the SOAPEnvelope to make sure we've got the right
    // protocol namespace there as well.
    SOAPEnvelope soapEnv = (SOAPEnvelope) m.getAsOMElement();
    OMNamespace ns = soapEnv.getNamespace();
    assertTrue(ns.getNamespaceURI().equals(SOAP12_NS_URI));
    
    // Assuming no handlers are installed, the next thing that will happen
    // is the proxy code will ask for the business object (String).
    XMLStringBlockFactory blockFactory = 
        (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
    Block block = m.getBodyBlock(null, blockFactory);
    Object bo = block.getBusinessObject(true);
    assertTrue(bo instanceof String);
    
    // The block should be consumed
    assertTrue(block.isConsumed());
    
    // Check the String for accuracy
    assertTrue(sampleText.equals(bo));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:38,代码来源:SOAP12Tests.java

示例7: testGetMessageFromSoap12

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void testGetMessageFromSoap12() throws Exception {
    // On inbound, there will already be an OM
    // which represents the message.  The following code simulates the input
    // OM
    StringReader sr = new StringReader(sampleSoap12Envelope);
    XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
    OMElement omElement = builder.getSOAPEnvelope();
    
    // The JAX-WS layer creates a Message from the OM
    MessageFactory mf = (MessageFactory)
        FactoryRegistry.getFactory(MessageFactory.class);
    Message m = mf.createFrom(omElement, null);
    
    // Make sure the right Protocol was set on the Message
    assertTrue(m.getProtocol().equals(Protocol.soap12));
    
    // Check the SOAPEnvelope to make sure we've got the right
    // protocol namespace there as well.
    SOAPEnvelope soapEnv = (SOAPEnvelope) m.getAsOMElement();
    OMNamespace ns = soapEnv.getNamespace();
    assertTrue(ns.getNamespaceURI().equals(SOAP12_NS_URI));
    
    // Assuming no handlers are installed, the next thing that will happen
    // is the proxy code will ask for the business object (String).
    XMLStringBlockFactory blockFactory = 
        (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
    Block block = blockFactory.createFrom(m.getAsOMElement(), null, null);
    Object bo = block.getBusinessObject(true);
    assertTrue(bo instanceof String);
    
    // The block should be consumed
    assertTrue(block.isConsumed());
    
    // Check the String for accuracy
    assertTrue(((String)bo).contains("<soapenv:Body><echo>test string</echo></soapenv:Body>"));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:38,代码来源:SOAP12Tests.java

示例8: test1

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
/**
 * @testStrategy Tests conversions between SAAJ and OM SOAPEnvelopes
 */
public void test1() throws Exception {
	
	// Bootstrap: Create an OM SOAPEnvelope from the sample text
	StringReader sr = new StringReader(sampleEnvelope);
	XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
	StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
	org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
	
	// Step 1: Get the SAAJConverter object from the Factory
	SAAJConverterFactory f = (SAAJConverterFactory) 
		FactoryRegistry.getFactory(SAAJConverterFactory.class);
	SAAJConverter converter = f.getSAAJConverter();
	
	// Step 2: Convert the OM SOAPEnvelope to an SAAJ SOAPEnvelope
	SOAPEnvelope saajEnvelope = converter.toSAAJ(omEnvelope);
	
	// Step 2a: Simple assertion check to ensure correctness.
	String name = saajEnvelope.getBody().getFirstChild().getLocalName();
	assertTrue("a".equals(name));
	
	// Step 3: Convert the SAAJ SOAPEnvelope to an OM SOAPEnvelope
	omEnvelope = converter.toOM(saajEnvelope);
	
	// Step 3a: Simple assertion check to ensure correctness
	name = omEnvelope.getBody().getFirstElement().getLocalName();
	assertTrue("a".equals(name));
	
	// Step 4: Rinse and repeat
	saajEnvelope = converter.toSAAJ(omEnvelope);
	name = saajEnvelope.getBody().getFirstChild().getLocalName();
	assertTrue("a".equals(name));
	omEnvelope = converter.toOM(saajEnvelope);
	name = omEnvelope.getBody().getFirstElement().getLocalName();
	assertTrue("a".equals(name));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:39,代码来源:SAAJConverterTests.java

示例9: _testStringInflow

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void _testStringInflow(String sampleEnvelope) throws Exception {

        // On inbound, there will already be an OM
        // which represents the message. The following code simulates the input
        // OM
        StringReader sr = new StringReader(sampleEnvelope);
        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
        OMElement omElement = builder.getSOAPEnvelope();

        // The JAX-WS layer creates a Message from the OM
        MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
        Message m = mf.createFrom(omElement, null);

        // 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(),
                   "OM".equals(m.getXMLPartContentType()));

        // Assuming no handlers are installed, the next thing that will happen
        // is the proxy code will ask for the business object (String).
        XMLStringBlockFactory blockFactory =
                (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
        Block block = m.getBodyBlock(null, blockFactory);
        Object bo = block.getBusinessObject(true);
        assertTrue(bo instanceof String);

        // The block should be consumed
        assertTrue(block.isConsumed());

        // Check the String for accuracy
        assertTrue(sampleText.equals(bo.toString()));

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

示例10: _testStringInflow4

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void _testStringInflow4(String sampleEnvelopeNoHeader) throws Exception {
    // On inbound, there will already be an OM
    // which represents the message.  The following code simulates the input
    // OM
    StringReader sr = new StringReader(sampleEnvelopeNoHeader);
    XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
    OMElement omElement = builder.getSOAPEnvelope();
    
    // The JAX-WS layer creates a Message from the OM
    MessageFactory mf = (MessageFactory)
        FactoryRegistry.getFactory(MessageFactory.class);
    Message m = mf.createFrom(omElement, null);
    
    // 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(),
                "OM".equals(m.getXMLPartContentType()));
    
    // The next thing that will happen
    // is the proxy code will ask for the business object (String).
    XMLStringBlockFactory blockFactory = 
        (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
    Block block = m.getBodyBlock(null, blockFactory);
    Object bo = block.getBusinessObject(true);
    assertTrue(bo instanceof String);
    
    // The block should be consumed
    assertTrue(block.isConsumed());
    
    // Check the String for accuracy
    assertTrue(sampleText.equals(bo.toString()));
    
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:37,代码来源:MessageTests.java

示例11: testStringInflow1

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
/**
 * This test effectively tests XMLFault construction from
 * 
 * org.apache.axiom.soap.SOAPFault soapfault, List<Block> detailBlks
 * 
 * which is a client-side operation.  Also tests the "serialization" of the
 * XMLFault object into a Message object which is a server-side operation.
 * 
 * @throws Exception
 */

public void testStringInflow1() throws Exception {
	
	try {
	// On inbound, there will already be an OM
	// which represents the message.  The following code simulates the input
	// OM
	StringReader sr = new StringReader(sampleSOAP11FaultEnvelope1);
	XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
	StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
	OMElement omElement = builder.getSOAPEnvelope();
	
	// The JAX-WS layer creates a Message from the OM
	MessageFactory mf = (MessageFactory)
		FactoryRegistry.getFactory(MessageFactory.class);
	Message m = mf.createFrom(omElement, null);
	
	assertTrue(m.isFault());
	
	if (m.isFault()) {
		XMLFault x = m.getXMLFault();
		assertEquals(faultString + "sampleSOAP11FaultEnvelope1", x.getReason().getText());
		assertEquals("Server", x.getCode().
                   toQName("http://schemas.xmlsoap.org/soap/envelope/").getLocalPart());
	} else {
		fail("Message should be marked as a fault.");
	}
	
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.toString());
	}

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

示例12: testStringInflow3

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
/**
 * This test effectively tests XMLFault construction from
 * 
 * org.apache.axiom.soap.SOAPFault soapfault, List<Block> detailBlks
 * 
 * which is a client-side operation.  Also tests the "serialization" of the
 * XMLFault object into a Message object which is a server-side operation.
 * 
 * @throws Exception
 */

public void testStringInflow3() throws Exception {
	
	try {
	// On inbound, there will already be an OM
	// which represents the message.  The following code simulates the input
	// OM
	StringReader sr = new StringReader(sampleSOAP12FaultEnvelope1);
	XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
	StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
	OMElement omElement = builder.getSOAPEnvelope();
	
	// The JAX-WS layer creates a Message from the OM
	MessageFactory mf = (MessageFactory)
		FactoryRegistry.getFactory(MessageFactory.class);
	Message m = mf.createFrom(omElement, null);
	
	assertTrue(m.isFault());
	
	if (m.isFault()) {
		XMLFault x = m.getXMLFault();
		assertEquals(faultString + "sampleSOAP12FaultEnvelope1", x.getReason().getText());
           assertEquals("Receiver", x.getCode().
                   toQName("http://www.w3.org/2003/05/soap-envelope").getLocalPart());
	} else {
		fail("Message should be marked as a fault.");
	}
	
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.toString());
	}
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:44,代码来源:FaultTests.java

示例13: testStringInflow4

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public void testStringInflow4() throws Exception {
    
    try {
    // On inbound, there will already be an OM
    // which represents the message.  The following code simulates the input
    // OM
    StringReader sr = new StringReader(sampleSOAP12FaultEnvelope2);
    XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
    OMElement omElement = builder.getSOAPEnvelope();
    
    // The JAX-WS layer creates a Message from the OM
    MessageFactory mf = (MessageFactory)
        FactoryRegistry.getFactory(MessageFactory.class);
    Message m = mf.createFrom(omElement, null);
    
    assertTrue(m.isFault());
    
    if (m.isFault()) {
        XMLFault x = m.getXMLFault();
        assertEquals(faultString + "sampleSOAP12FaultEnvelope2", x.getReason().getText());
        assertEquals("Sender", x.getCode().
                toQName("http://www.w3.org/2003/05/soap-envelope").getLocalPart());
    } else {
        fail("Message should be marked as a fault.");
    }
    
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.toString());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:33,代码来源:FaultTests.java

示例14: getSOAPEnvelopeFromDOOMDocument

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public static org.apache.axiom.soap.SOAPEnvelope
        getSOAPEnvelopeFromDOOMDocument(org.w3c.dom.Document doc) {

    OMElement docElem = (OMElement)doc.getDocumentElement();
    StAXSOAPModelBuilder stAXSOAPModelBuilder =
            new StAXSOAPModelBuilder(docElem.getXMLStreamReader(), null);
    return stAXSOAPModelBuilder.getSOAPEnvelope();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:SAAJUtil.java

示例15: toOMSOAPEnvelope

import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; //导入方法依赖的package包/类
public static org.apache.axiom.soap.SOAPEnvelope
        toOMSOAPEnvelope(org.w3c.dom.Element elem) {

    OMElement docElem = (OMElement)elem;
    StAXSOAPModelBuilder stAXSOAPModelBuilder =
            new StAXSOAPModelBuilder(docElem.getXMLStreamReader(), null);
    return stAXSOAPModelBuilder.getSOAPEnvelope();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:SAAJUtil.java


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