use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class SOAPSampleAdapter method getSOAPEnvelope.
public SOAPEnvelope getSOAPEnvelope(OMMetaFactory metaFactory) {
SOAPEnvelope envelope = getBuilder(metaFactory).getSOAPEnvelope();
// TODO: this is not the right place to assert this
Assert.assertSame(sample.getSOAPSpec().getEnvelopeNamespaceURI(), ((SOAPFactory) envelope.getOMFactory()).getSoapVersionURI());
return envelope;
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestRegisterCustomBuilderForPayload method runTest.
@Override
protected void runTest() throws Throwable {
SOAPModelBuilder builder = message.getAdapter(SOAPSampleAdapter.class).getBuilder(metaFactory);
((CustomBuilderSupport) builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, new BlobOMDataSourceCustomBuilder(MemoryBlob.FACTORY, "utf-8"));
SOAPEnvelope envelope = builder.getSOAPEnvelope();
OMElement payload = envelope.getBody().getFirstElement();
if (message.getPayload() == null) {
assertThat(payload).isNull();
} else if (message.getPayload().getLocalName().equals("Fault")) {
assertThat(payload).isInstanceOf(SOAPFault.class);
} else {
assertThat(payload).isInstanceOf(OMSourcedElement.class);
BlobOMDataSource.Data data = (BlobOMDataSource.Data) ((OMSourcedElement) payload).getObject(BlobOMDataSource.class);
assertThat(data).isNotNull();
InputSource is = new InputSource(data.getBlob().getInputStream());
is.setEncoding(data.getEncoding());
assertAbout(xml()).that(is).ignoringNamespaceDeclarations().hasSameContentAs(message.getPayloadInputSource());
}
// We need to ignore redundant namespace declarations because the custom builder needs
// to preserve the namespace context when serializing to the blob.
assertAbout(xml()).that(envelope.getXMLStreamReader(false)).ignoringPrologAndEpilog().ignoringRedundantNamespaceDeclarations().hasSameContentAs(message.getInputStream());
if (payload instanceof OMSourcedElement) {
assertThat(((OMSourcedElement) payload).isExpanded()).isFalse();
}
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestAddElementAfterBody method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope env = soapFactory.createSOAPEnvelope();
if (header) {
soapFactory.createSOAPHeader(env);
}
soapFactory.createSOAPBody(env);
OMElement elem = env.getOMFactory().createOMElement(new QName("foo"));
if (spec.isAllowsElementsAfterBody()) {
env.addChild(elem);
} else {
try {
env.addChild(elem);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// expected
}
}
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestCloneWithSourcedElement1 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope sourceEnv = soapFactory.getDefaultEnvelope();
SOAPBody body = sourceEnv.getBody();
// Create a payload
OMDataSource bads = new StringOMDataSource("<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>");
OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
OMSourcedElement omse = body.getOMFactory().createOMElement(bads, "payload", ns);
body.addChild(omse);
copyAndCheck(sourceEnv);
assertFalse(omse.isExpanded());
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestGetSOAPBodyFirstElementLocalNameAndNS method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
OMElement bodyElement = soapFactory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix());
envelope.getBody().addChild(bodyElement);
assertEquals(qname.getLocalPart(), envelope.getSOAPBodyFirstElementLocalName());
OMNamespace ns = envelope.getSOAPBodyFirstElementNS();
if (qname.getNamespaceURI().length() == 0) {
assertNull(ns);
} else {
assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
assertEquals(qname.getPrefix(), ns.getPrefix());
}
}
Aggregations