XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults));
StAXOMBuilder resultsBuilder = new StAXOMBuilder(reader);
OMElement resultSer = resultsBuilder.getDocumentElement();
// create the response soap
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope resEnv = factory.createSOAPEnvelope();
SOAPBody resBody = factory.createSOAPBody();
OMElement resService = factory.createOMElement(new QName(serviceName + "Response"));
resService.addChild(resultSer.getFirstElement());
resBody.addChild(resService);
resEnv.addChild(resBody);
// The declareDefaultNamespace method doesn't work see (https://issues.apache.org/jira/browse/AXIS2-3156)
// so the following doesn't work:
// resService.declareDefaultNamespace(ModelService.TNS);
// instead, create the xmlns attribute directly:
OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS);
resService.addAttribute(defaultNS);
// log the response message
if (Debug.verboseOn()) {
try {