List of usage examples for javax.xml.soap SOAPEnvelope getBody
public SOAPBody getBody() throws SOAPException;
From source file:edu.duke.cabig.c3pr.webservice.integration.StudyImportExportWebServiceTest.java
private SOAPMessage prepareRequestEnvelope(String xmlFile, String wrapperElement) throws SOAPException, DOMException, IOException, SAXException, ParserConfigurationException { MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); SOAPMessage reqMsg = mf.createMessage(); SOAPPart part = reqMsg.getSOAPPart(); SOAPEnvelope env = part.getEnvelope(); SOAPBody body = env.getBody(); SOAPElement operation = body.addChildElement(wrapperElement, "stud", SERVICE_NS); operation.appendChild(env.getOwnerDocument().importNode(getSOAPBodyFromXML(xmlFile), true)); reqMsg.saveChanges();//www . j ava 2 s.c om return reqMsg; }
From source file:edu.duke.cabig.c3pr.webservice.integration.StudyImportExportWebServiceTest.java
private void doStudyExportCheck() throws DOMException, SOAPException, IOException, SAXException, ParserConfigurationException { String xmlFile = "StudyIdentifier"; Dispatch<SOAPMessage> dispatch = getDispatch(); SOAPMessage reqMsg = prepareExportRequestEnvelope(xmlFile); SOAPMessage respMsg = dispatch.invoke(reqMsg); SOAPPart part = respMsg.getSOAPPart(); SOAPEnvelope env = part.getEnvelope(); SOAPBody body = env.getBody(); NodeList nodes = body.getElementsByTagNameNS(SERVICE_NS, "ExportStudyResponse"); assertEquals(1, nodes.getLength());/*w ww. j a va 2s. c o m*/ Element responseEl = (Element) nodes.item(0); assertEquals(1, responseEl.getChildNodes().getLength()); Element exportedStudy = (Element) responseEl.getChildNodes().item(0); // this study element must match the one used to create the study in the first place Element originalStudy = (Element) getSOAPBodyFromXML("Study"); assertTrue(XMLUtils.isDeepEqual(exportedStudy, originalStudy)); }
From source file:org.cleverbus.core.reqres.RequestResponseTest.java
/** * Test saving synchronous request/response where response is failed SOAP fault exception. *//* w w w .ja va2 s .com*/ @Test public void testSavingRequestWithSOAPFaultResponse() throws Exception { final String soapFault = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<SOAP-ENV:Fault xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" + " <faultcode>SOAP-ENV:Server</faultcode>" + " <faultstring>There is one error</faultstring>" + "</SOAP-ENV:Fault>"; // prepare target route prepareTargetRoute(TARGET_URI, new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.getOut().setBody(soapFault); // create SOAP Fault message SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); // Set fault code and fault string SOAPFault fault = soapBody.addFault(); fault.setFaultCode(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server")); fault.setFaultString("There is one error"); SoapMessage message = new SaajSoapMessage(soapMessage); throw new SoapFaultClientException(message); } }); // action mock.expectedMessageCount(0); try { producer.sendBody(REQUEST); fail("Target route was thrown exception."); } catch (CamelExecutionException ex) { assertRequestResponse(REQUEST, null, "org.springframework.ws.soap.client.SoapFaultClientException: There is one error", soapFault); } }
From source file:cl.nic.dte.net.ConexionSii.java
@SuppressWarnings("unchecked") private String getSemilla() throws UnsupportedOperationException, SOAPException, IOException, XmlException, ConexionSiiException { SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance(); SOAPConnection con = scFactory.createConnection(); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPHeader header = envelope.getHeader(); SOAPBody body = envelope.getBody(); header.detachNode();/* w w w. ja v a2 s . c om*/ String urlSolicitud = Utilities.netLabels.getString("URL_SOLICITUD_SEMILLA"); Name bodyName = envelope.createName("getSeed", "m", urlSolicitud); message.getMimeHeaders().addHeader("SOAPAction", ""); body.addBodyElement(bodyName); URL endpoint = new URL(urlSolicitud); SOAPMessage responseSII = con.call(message, endpoint); SOAPPart sp = responseSII.getSOAPPart(); SOAPBody b = sp.getEnvelope().getBody(); cl.sii.xmlSchema.RESPUESTADocument resp = null; for (Iterator<SOAPBodyElement> res = b.getChildElements( sp.getEnvelope().createName("getSeedResponse", "ns1", urlSolicitud)); res.hasNext();) { for (Iterator<SOAPBodyElement> ret = res.next().getChildElements( sp.getEnvelope().createName("getSeedReturn", "ns1", urlSolicitud)); ret.hasNext();) { HashMap<String, String> namespaces = new HashMap<String, String>(); namespaces.put("", "http://www.sii.cl/XMLSchema"); XmlOptions opts = new XmlOptions(); opts.setLoadSubstituteNamespaces(namespaces); resp = RESPUESTADocument.Factory.parse(ret.next().getValue(), opts); } } if (resp != null && resp.getRESPUESTA().getRESPHDR().getESTADO() == 0) { return resp.getRESPUESTA().getRESPBODY().getSEMILLA(); } else { throw new ConexionSiiException( "No obtuvo Semilla: Codigo: " + resp.getRESPUESTA().getRESPHDR().getESTADO() + "; Glosa: " + resp.getRESPUESTA().getRESPHDR().getGLOSA()); } }
From source file:com.cisco.dvbu.ps.common.adapters.connect.SoapHttpConnector.java
private Document send(SoapHttpConnectorCallback cb, String requestXml) throws AdapterException { log.debug("Entered send: " + cb.getName()); // set up the factories and create a SOAP factory SOAPConnection soapConnection; Document doc = null;// w w w. j a v a 2s . c o m URL endpoint = null; try { soapConnection = SOAPConnectionFactory.newInstance().createConnection(); MessageFactory messageFactory = MessageFactory.newInstance(); // Create a message from the message factory. SOAPMessage soapMessage = messageFactory.createMessage(); // Set the SOAP Action here MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", cb.getAction()); // set credentials // String authorization = new sun.misc.BASE64Encoder().encode((shConfig.getUser() + "@" + shConfig.getDomain() + ":" + shConfig.getPassword()).getBytes()); String authorization = new String(org.apache.commons.codec.binary.Base64.encodeBase64( (shConfig.getUser() + "@" + shConfig.getDomain() + ":" + shConfig.getPassword()).getBytes())); headers.addHeader("Authorization", "Basic " + authorization); log.debug("Authentication: " + authorization); // create a SOAP part have populate the envelope SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.setEncodingStyle(SOAPConstants.URI_NS_SOAP_ENCODING); SOAPHeader head = envelope.getHeader(); if (head == null) head = envelope.addHeader(); // create a SOAP body SOAPBody body = envelope.getBody(); log.debug("Request XSL Style Sheet:\n" + XMLUtils.getPrettyXml(XMLUtils.getDocumentFromString(cb.getRequestBodyXsl()))); // convert request string to document and then transform body.addDocument(XmlUtils.xslTransform(XmlUtils.stringToDocument(requestXml), cb.getRequestBodyXsl())); // build the request structure soapMessage.saveChanges(); log.debug("Soap request successfully built: "); log.debug(" Body:\n" + XMLUtils.getPrettyXml(XMLUtils.getDocumentFromString(XmlUtils.nodeToString(body)))); if (shConfig.useProxy()) { System.setProperty("http.proxySet", "true"); System.setProperty("http.proxyHost", shConfig.getProxyHost()); System.setProperty("http.proxyPort", "" + shConfig.getProxyPort()); if (shConfig.useProxyCredentials()) { System.setProperty("http.proxyUser", shConfig.getProxyUser()); System.setProperty("http.proxyPassword", shConfig.getProxyPassword()); } } endpoint = new URL(shConfig.getEndpoint(cb.getEndpoint())); // now make that call over the SOAP connection SOAPMessage reply = null; AdapterException ae = null; for (int i = 1; (i <= shConfig.getRetryAttempts() && reply == null); i++) { log.debug("Attempt " + i + ": sending request to endpoint: " + endpoint); try { reply = soapConnection.call(soapMessage, endpoint); log.debug("Attempt " + i + ": received response: " + reply); } catch (Exception e) { ae = new AdapterException(502, String.format(AdapterConstants.ADAPTER_EM_CONNECTION, endpoint), e); Thread.sleep(100); } } // close down the connection soapConnection.close(); if (reply == null) throw ae; SOAPFault fault = reply.getSOAPBody().getFault(); if (fault == null) { doc = reply.getSOAPBody().extractContentAsDocument(); } else { // Extracts the entire Soap Fault message coming back from CIS String faultString = XmlUtils.nodeToString(fault); throw new AdapterException(503, faultString, null); } } catch (AdapterException e) { throw e; } catch (Exception e) { throw new AdapterException(504, String.format(AdapterConstants.ADAPTER_EM_CONNECTION, shConfig.getEndpoint(cb.getEndpoint())), e); } finally { if (shConfig.useProxy()) { System.setProperty("http.proxySet", "false"); } } log.debug("Exiting send: " + cb.getName()); return doc; }
From source file:com.ibm.soatf.component.soap.SOAPComponent.java
private void checkSOAPMessage(boolean ok) throws SoapComponentException { ProgressMonitor.init(2, "Loading message from file..."); String filename = new StringBuilder(serviceName).append(NAME_DELIMITER).append(operationName) .append(NAME_DELIMITER).append(RESPONSE_FILE_SUFFIX).toString(); final File file = new File(workingDir, filename); InputStream is = null;//from ww w.j av a2s .co m try { final byte[] xmlMessage = FileUtils.readFileToByteArray(file); is = new ByteArrayInputStream(xmlMessage); SOAPMessage response = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL) .createMessage(new MimeHeaders(), is); ProgressMonitor.increment("Checking for fault..."); response.removeAllAttachments(); SOAPEnvelope envp = response.getSOAPPart().getEnvelope(); SOAPBody someBody = envp.getBody(); if (ok) { if (someBody.getFault() == null) { cor.addMsg("soap body is OK"); cor.markSuccessful(); } else { final String msg = "found soap fault in response body:\n" + new String(xmlMessage); cor.addMsg(msg); throw new SoapComponentException(msg); } } else { if (someBody.getFault() != null) { cor.addMsg("found soap fault in response body"); cor.markSuccessful(); } else { final String msg = "response body doesn't contain soap fault:\n" + new String(xmlMessage); cor.addMsg(msg); throw new SoapComponentException(msg); } } } catch (IOException | SOAPException ex) { throw new SoapComponentException("error while trying to parse response", ex); } finally { if (is != null) { try { is.close(); } catch (IOException ex) { logger.debug("Not able to close input stream. ", ex); } } } }
From source file:cl.nic.dte.net.ConexionSii.java
@SuppressWarnings("unchecked") public String getToken(PrivateKey pKey, X509Certificate cert) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException, SAXException, IOException, ParserConfigurationException, XmlException, UnsupportedOperationException, SOAPException, ConexionSiiException { String urlSolicitud = Utilities.netLabels.getString("URL_SOLICITUD_TOKEN"); String semilla = getSemilla(); GetTokenDocument req = GetTokenDocument.Factory.newInstance(); req.addNewGetToken().addNewItem().setSemilla(semilla); HashMap<String, String> namespaces = new HashMap<String, String>(); namespaces.put("", "http://www.sii.cl/SiiDte"); XmlOptions opts = new XmlOptions(); opts = new XmlOptions(); opts.setSaveImplicitNamespaces(namespaces); opts.setLoadSubstituteNamespaces(namespaces); opts.setSavePrettyPrint();//from w ww. ja v a 2s . com opts.setSavePrettyPrintIndent(0); req = GetTokenDocument.Factory.parse(req.newInputStream(opts), opts); // firmo req.sign(pKey, cert); SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance(); SOAPConnection con = scFactory.createConnection(); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPHeader header = envelope.getHeader(); SOAPBody body = envelope.getBody(); header.detachNode(); Name bodyName = envelope.createName("getToken", "m", urlSolicitud); SOAPBodyElement gltp = body.addBodyElement(bodyName); Name toKname = envelope.createName("pszXml"); SOAPElement toKsymbol = gltp.addChildElement(toKname); opts = new XmlOptions(); opts.setCharacterEncoding("ISO-8859-1"); opts.setSaveImplicitNamespaces(namespaces); toKsymbol.addTextNode(req.xmlText(opts)); message.getMimeHeaders().addHeader("SOAPAction", ""); URL endpoint = new URL(urlSolicitud); message.writeTo(System.out); SOAPMessage responseSII = con.call(message, endpoint); SOAPPart sp = responseSII.getSOAPPart(); SOAPBody b = sp.getEnvelope().getBody(); cl.sii.xmlSchema.RESPUESTADocument resp = null; for (Iterator<SOAPBodyElement> res = b.getChildElements( sp.getEnvelope().createName("getTokenResponse", "ns1", urlSolicitud)); res.hasNext();) { for (Iterator<SOAPBodyElement> ret = res.next().getChildElements( sp.getEnvelope().createName("getTokenReturn", "ns1", urlSolicitud)); ret.hasNext();) { namespaces = new HashMap<String, String>(); namespaces.put("", "http://www.sii.cl/XMLSchema"); opts.setLoadSubstituteNamespaces(namespaces); resp = RESPUESTADocument.Factory.parse(ret.next().getValue(), opts); } } if (resp != null && resp.getRESPUESTA().getRESPHDR().getESTADO() == 0) { return resp.getRESPUESTA().getRESPBODY().getTOKEN(); } else { throw new ConexionSiiException( "No obtuvo Semilla: Codigo: " + resp.getRESPUESTA().getRESPHDR().getESTADO() + "; Glosa: " + resp.getRESPUESTA().getRESPHDR().getGLOSA()); } }
From source file:cl.nic.dte.net.ConexionSii.java
@SuppressWarnings("unchecked") private RESPUESTADocument getEstadoDTE(String rutConsultante, Documento dte, String token, String urlSolicitud) throws UnsupportedOperationException, SOAPException, MalformedURLException, XmlException { String rutEmisor = dte.getEncabezado().getEmisor().getRUTEmisor(); String rutReceptor = dte.getEncabezado().getReceptor().getRUTRecep(); Integer tipoDTE = dte.getEncabezado().getIdDoc().getTipoDTE().intValue(); long folioDTE = dte.getEncabezado().getIdDoc().getFolio(); String fechaEmision = Utilities.fechaEstadoDte .format(dte.getEncabezado().getIdDoc().getFchEmis().getTime()); long montoTotal = dte.getEncabezado().getTotales().getMntTotal(); SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance(); SOAPConnection con = scFactory.createConnection(); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPHeader header = envelope.getHeader(); SOAPBody body = envelope.getBody(); header.detachNode();/*w w w . j a v a 2 s. c om*/ Name bodyName = envelope.createName("getEstDte", "m", urlSolicitud); SOAPBodyElement gltp = body.addBodyElement(bodyName); Name toKname = envelope.createName("RutConsultante"); SOAPElement toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(rutConsultante.substring(0, rutConsultante.length() - 2)); toKname = envelope.createName("DvConsultante"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(rutConsultante.substring(rutConsultante.length() - 1, rutConsultante.length())); toKname = envelope.createName("RutCompania"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(rutEmisor.substring(0, rutEmisor.length() - 2)); toKname = envelope.createName("DvCompania"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(rutEmisor.substring(rutEmisor.length() - 1, rutEmisor.length())); toKname = envelope.createName("RutReceptor"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(rutReceptor.substring(0, rutReceptor.length() - 2)); toKname = envelope.createName("DvReceptor"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(rutReceptor.substring(rutReceptor.length() - 1, rutReceptor.length())); toKname = envelope.createName("TipoDte"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(Integer.toString(tipoDTE)); toKname = envelope.createName("FolioDte"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(Long.toString(folioDTE)); toKname = envelope.createName("FechaEmisionDte"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(fechaEmision); toKname = envelope.createName("MontoDte"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(Long.toString(montoTotal)); toKname = envelope.createName("Token"); toKsymbol = gltp.addChildElement(toKname); toKsymbol.addTextNode(token); message.getMimeHeaders().addHeader("SOAPAction", ""); URL endpoint = new URL(urlSolicitud); SOAPMessage responseSII = con.call(message, endpoint); SOAPPart sp = responseSII.getSOAPPart(); SOAPBody b = sp.getEnvelope().getBody(); for (Iterator<SOAPBodyElement> res = b.getChildElements( sp.getEnvelope().createName("getEstDteResponse", "ns1", urlSolicitud)); res.hasNext();) { for (Iterator<SOAPBodyElement> ret = res.next().getChildElements( sp.getEnvelope().createName("getEstDteReturn", "ns1", urlSolicitud)); ret.hasNext();) { HashMap<String, String> namespaces = new HashMap<String, String>(); namespaces.put("", "http://www.sii.cl/XMLSchema"); XmlOptions opts = new XmlOptions(); opts.setLoadSubstituteNamespaces(namespaces); return RESPUESTADocument.Factory.parse(ret.next().getValue(), opts); } } return null; }
From source file:it.cnr.icar.eric.server.interfaces.soap.RegistryBSTServlet.java
public SOAPMessage onMessage(SOAPMessage msg, HttpServletRequest req, HttpServletResponse resp) { //System.err.println("onMessage called for RegistrySOAPServlet"); SOAPMessage soapResponse = null; SOAPHeader sh = null;/*from w w w . ja v a2s .c o m*/ try { // set 'sh' variable ASAP (before "firstly") SOAPPart sp = msg.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); SOAPBody sb = se.getBody(); sh = se.getHeader(); // Firstly we put save the attached repository items in a map HashMap<String, Object> idToRepositoryItemMap = new HashMap<String, Object>(); Iterator<?> apIter = msg.getAttachments(); while (apIter.hasNext()) { AttachmentPart ap = (AttachmentPart) apIter.next(); //Get the content for the attachment RepositoryItem ri = processIncomingAttachment(ap); idToRepositoryItemMap.put(ri.getId(), ri); } // Log received message //if (log.isTraceEnabled()) { // Warning! BAOS.toString() uses platform's default encoding /* ByteArrayOutputStream msgOs = new ByteArrayOutputStream(); msg.writeTo(msgOs); msgOs.close(); System.err.println(msgOs.toString()); */ //System.err.println(sb.getTextContent()); // log.trace("incoming message:\n" + msgOs.toString()); //} // verify signature // returns false if no security header, throws exception if invalid CredentialInfo credentialInfo = new CredentialInfo(); boolean noRegRequired = Boolean.valueOf( CommonProperties.getInstance().getProperty("eric.common.noUserRegistrationRequired", "false")) .booleanValue(); if (!noRegRequired) { WSS4JSecurityUtilBST.verifySOAPEnvelopeOnServerBST(se, credentialInfo); } //The ebXML registry request is the only element in the SOAPBody StringWriter requestXML = new StringWriter(); //The request as an XML String String requestRootElement = null; Iterator<?> iter = sb.getChildElements(); int i = 0; while (iter.hasNext()) { Object obj = iter.next(); if (!(obj instanceof SOAPElement)) { continue; } if (i++ == 0) { SOAPElement elem = (SOAPElement) obj; Name name = elem.getElementName(); requestRootElement = name.getLocalName(); StreamResult result = new StreamResult(requestXML); TransformerFactory tf = TransformerFactory.newInstance(); Transformer trans = tf.newTransformer(); trans.transform(new DOMSource(elem), result); } else { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.invalidRequest")); } } if (requestRootElement == null) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.noebXMLRegistryRequest")); } // unmarshalling request to message Object message = bu.getRequestObject(requestRootElement, requestXML.toString()); if (message instanceof JAXBElement<?>) { // If Element; take ComplexType from Element message = ((JAXBElement<?>) message).getValue(); } // request sets ServerContext with ComplexType: RegistryObjectType BSTRequest request = new BSTRequest(req, credentialInfo, message, idToRepositoryItemMap); Response response = request.process(); // response.getMessage() is ComplexType again soapResponse = createResponseSOAPMessage(response); if (response.getIdToRepositoryItemMap().size() > 0 && (response.getMessage().getStatus() .equals(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success))) { idToRepositoryItemMap = response.getIdToRepositoryItemMap(); Iterator<?> mapKeysIter = idToRepositoryItemMap.keySet().iterator(); while (mapKeysIter.hasNext()) { String id = (String) mapKeysIter.next(); RepositoryItem repositoryItem = (RepositoryItem) idToRepositoryItemMap.get(id); String cid = WSS4JSecurityUtilBST.convertUUIDToContentId(id); DataHandler dh = repositoryItem.getDataHandler(); AttachmentPart ap = soapResponse.createAttachmentPart(dh); ap.setMimeHeader("Content-Type", "text/xml"); ap.setContentId(cid); soapResponse.addAttachmentPart(ap); if (log.isTraceEnabled()) { log.trace("adding attachment: contentId=" + id); } } } } catch (Throwable t) { //Do not log ObjectNotFoundException as it clutters the log if (!(t instanceof ObjectNotFoundException)) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException", new Object[] { t.getMessage() }), t); Throwable cause = t.getCause(); while (cause != null) { log.error(ServerResourceBundle.getInstance().getString("message.CausedBy", new Object[] { cause.getMessage() }), cause); cause = cause.getCause(); } } soapResponse = createFaultSOAPMessage(t, sh); } if (log.isTraceEnabled()) { try { ByteArrayOutputStream rspOs = new ByteArrayOutputStream(); soapResponse.writeTo(rspOs); rspOs.close(); // Warning! BAOS.toString() uses platform's default encoding log.trace("response message:\n" + rspOs.toString()); } catch (Exception e) { log.error(ServerResourceBundle.getInstance().getString("message.FailedToLogResponseMessage", new Object[] { e.getMessage() }), e); } } return soapResponse; }
From source file:net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuter.java
protected SOAPMessage createQueryMessage() { String queryStr = getQueryString(); if (log.isDebugEnabled()) { log.debug("MDX query: " + queryStr); }/* ww w. j a v a2 s.co m*/ try { MessageFactory mf = MessageFactory.newInstance(); SOAPMessage message = mf.createMessage(); MimeHeaders mh = message.getMimeHeaders(); mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\""); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); Name nEx = envelope.createName("Execute", "", XMLA_URI); SOAPElement eEx = body.addChildElement(nEx); // add the parameters // COMMAND parameter // <Command> // <Statement>queryStr</Statement> // </Command> Name nCom = envelope.createName("Command", "", XMLA_URI); SOAPElement eCommand = eEx.addChildElement(nCom); Name nSta = envelope.createName("Statement", "", XMLA_URI); SOAPElement eStatement = eCommand.addChildElement(nSta); eStatement.addTextNode(queryStr); // <Properties> // <PropertyList> // <DataSourceInfo>dataSource</DataSourceInfo> // <Catalog>catalog</Catalog> // <Format>Multidimensional</Format> // <AxisFormat>TupleFormat</AxisFormat> // </PropertyList> // </Properties> Map<String, String> paraList = new HashMap<String, String>(); String datasource = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE); paraList.put("DataSourceInfo", datasource); String catalog = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG); paraList.put("Catalog", catalog); paraList.put("Format", "Multidimensional"); paraList.put("AxisFormat", "TupleFormat"); addParameterList(envelope, eEx, "Properties", "PropertyList", paraList); message.saveChanges(); if (log.isDebugEnabled()) { log.debug("XML/A query message: \n" + prettyPrintSOAP(message.getSOAPPart().getEnvelope())); } return message; } catch (SOAPException e) { throw new JRRuntimeException(e); } }