use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class ElementSerializerTest method testCompleteElement.
public void testCompleteElement() throws Exception {
SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
env.serialize(writer);
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class DataHandlerTest method test.
private void test(String feature) {
DataHandler dh = new DataHandler(new TestDataSource('x', 1000));
SOAPEnvelope envelope = OMAbstractFactory.getMetaFactory(feature).getSOAP11Factory().createDefaultSOAPMessage().getSOAPEnvelope();
PayloadHelper.setBinaryPayload(envelope, dh);
assertThat(PayloadHelper.getBinaryPayload(envelope)).isSameAs(dh);
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class ConvertLLOMToDOOMTest method testConvert1.
public void testConvert1() {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope env = fac.getDefaultEnvelope();
fac.createOMElement(new QName("http://test.org", "Test"), env.getBody());
env.build();
SOAPModelBuilder doomBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM), env.getXMLStreamReader());
SOAPEnvelope doomEnv = doomBuilder.getSOAPEnvelope();
doomEnv.build();
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestDataHandlerSerializationWithMTOM method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFactory factory = metaFactory.getSOAP11Factory();
JAXBContext context = JAXBContext.newInstance(DocumentBean.class);
// Construct the original message
DocumentBean object = new DocumentBean();
object.setId("123456");
object.setContent(new DataHandler("some content", "text/plain; charset=utf-8"));
SOAPEnvelope orgEnvelope = factory.getDefaultEnvelope();
OMSourcedElement element = factory.createOMElement(new JAXBOMDataSource(context, object));
orgEnvelope.getBody().addChild(element);
// Serialize the message
OMOutputFormat format = new OMOutputFormat();
format.setDoOptimize(true);
MemoryBlob blob = Blobs.createMemoryBlob();
OutputStream out = blob.getOutputStream();
orgEnvelope.serialize(out, format);
out.close();
assertFalse(element.isExpanded());
// Parse the serialized message
MultipartBody mb = MultipartBody.builder().setInputStream(blob.getInputStream()).setContentType(format.getContentType()).build();
assertEquals(2, mb.getPartCount());
SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, mb).getSOAPEnvelope();
OMElement contentElement = envelope.getBody().getFirstElement().getFirstChildWithName(new QName("http://ws.apache.org/axiom/test/jaxb", "content"));
OMText content = (OMText) contentElement.getFirstOMChild();
assertTrue(content.isBinary());
assertTrue(content.isOptimized());
DataHandler dh = content.getDataHandler();
assertEquals("some content", dh.getContent());
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestExtractAllHeaderBlocks method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPHeader header = soapFactory.createSOAPHeader(envelope);
OMNamespace ns = soapFactory.createOMNamespace("urn:ns", "p");
SOAPHeaderBlock h1 = header.addHeaderBlock("header1", ns);
SOAPHeaderBlock h2 = header.addHeaderBlock("header2", ns);
Iterator<SOAPHeaderBlock> it = header.extractAllHeaderBlocks();
assertTrue(it.hasNext());
assertSame(h1, it.next());
assertTrue(it.hasNext());
assertSame(h2, it.next());
assertFalse(it.hasNext());
}
Aggregations