use of org.apache.axiom.soap.SOAPEnvelope in project wso2-axis2-transports by wso2.
the class SimpleInOutMessageReceiver method invokeBusinessLogic.
public void invokeBusinessLogic(MessageContext inMessageContext, MessageContext outMessageContext) throws AxisFault {
log.debug("Got The message to the MessageReceiver");
String soapNamespace = inMessageContext.getEnvelope().getNamespace().getNamespaceURI();
// creating a soap factory according the the soap namespce uri
SOAPFactory soapFactory = null;
if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP11Factory();
} else if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP12Factory();
} else {
System.out.println("Unknow soap message");
}
SOAPEnvelope responseEnvelope = soapFactory.getDefaultEnvelope();
// creating a body element
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMNamespace omNamespace = omFactory.createOMNamespace("http://sms.test", "ns1");
OMElement omElement = omFactory.createOMElement("Response", omNamespace);
omElement.setText("Sucess");
responseEnvelope.getBody().addChild(omElement);
outMessageContext.setEnvelope(responseEnvelope);
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class ParserInputStreamDataSourceTests method updatePedsDataWithMockInputStream.
private void updatePedsDataWithMockInputStream(ParserInputStreamDataSource peds) throws Exception {
SOAPEnvelope env = getMockEnvelope();
SOAPBody body = env.getBody();
Iterator iter = body.getChildElements();
InputStream mockInputStream = null;
ByteArrayOutputStream os = new ByteArrayOutputStream();
while (iter.hasNext()) {
OMElement om = (OMElement) iter.next();
om.serialize(os);
byte[] bArray = os.toByteArray();
mockInputStream = new ByteArrayInputStream(bArray);
break;
}
((Data) peds.getObject()).setInputStream(mockInputStream);
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestWrongParent2 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope parent = soapFactory.createSOAPEnvelope();
OMElement child1 = soapFactory.createSOAPHeader(parent);
SOAPFault fault = soapFactory.createSOAPFault();
try {
child1.insertSiblingAfter(fault);
fail("Expected SOAPProcessingException");
} catch (SOAPProcessingException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestAddDetailEntry method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPBody body = soapFactory.createSOAPBody(envelope);
SOAPFault fault = soapFactory.createSOAPFault(body);
SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail(fault);
OMNamespace omNamespace = soapFactory.createOMNamespace("http://www.test.org", "test");
soapFaultDetail.addDetailEntry(soapFactory.createOMElement("DetailEntry1", omNamespace));
soapFaultDetail.addDetailEntry(soapFactory.createOMElement("DetailEntry2", omNamespace));
Iterator<OMElement> iterator = soapFaultDetail.getAllDetailEntries();
OMElement detailEntry1 = iterator.next();
assertNotNull("SOAP Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns empty iterator", detailEntry1);
assertEquals("SOAP Fault Detail Test : - detailEntry1 local name mismatch", "DetailEntry1", detailEntry1.getLocalName());
assertEquals("SOAP Fault Detail Test : - detailEntry1 namespace uri mismatch", "http://www.test.org", detailEntry1.getNamespace().getNamespaceURI());
OMElement detailEntry2 = iterator.next();
assertNotNull("SOAP Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns an iterator with only one object", detailEntry2);
assertEquals("SOAP Fault Detail Test : - detailEntry2 local name mismatch", "DetailEntry2", detailEntry2.getLocalName());
assertEquals("SOAP Fault Detail Test : - detailEntry2 namespace uri mismatch", "http://www.test.org", detailEntry2.getNamespace().getNamespaceURI());
assertFalse("SOAP Fault Detail Test : - After calling addDetailEntry method twice, getAllDetailEntries method returns an iterator with three objects", iterator.hasNext());
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestGetAllDetailEntries method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPBody body = soapFactory.createSOAPBody(envelope);
SOAPFault fault = soapFactory.createSOAPFault(body);
SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail(fault);
OMNamespace omNamespace = soapFactory.createOMNamespace("http://www.test.org", "test");
Iterator<OMElement> iterator = soapFaultDetail.getAllDetailEntries();
assertFalse("SOAP Fault Detail Test : - After creating SOAP11FaultDetail element, it has DetailEntries", iterator.hasNext());
soapFaultDetail.addDetailEntry(soapFactory.createOMElement("DetailEntry", omNamespace));
iterator = soapFaultDetail.getAllDetailEntries();
OMElement detailEntry = iterator.next();
assertNotNull("SOAP Fault Detail Test : - After calling addDetailEntry method, getAllDetailEntries method returns empty iterator", detailEntry);
assertEquals("SOAP Fault Detail Test : - detailEntry local name mismatch", "DetailEntry", detailEntry.getLocalName());
assertEquals("SOAP Fault Detail Test : - detailEntry namespace uri mismatch", "http://www.test.org", detailEntry.getNamespace().getNamespaceURI());
assertFalse("SOAP Fault Detail Test : - After calling addDetailEntry method once, getAllDetailEntries method returns an iterator with two objects", iterator.hasNext());
}
Aggregations