Example usage for javax.xml.soap SOAPMessage toString

List of usage examples for javax.xml.soap SOAPMessage toString

Introduction

In this page you can find the example usage for javax.xml.soap SOAPMessage toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.olap.OLAPQueryExecuter.java

protected SOAPMessage createQueryMessage(JRXMLADataSourceConnection xmlaConnection) {
    String queryStr = getQueryString();

    if (log.isDebugEnabled()) {
        log.debug("MDX query: " + queryStr);
    }/*www .ja v a  2s  .  c om*/

    try {
        // Force the use of Axis as message factory...

        MessageFactory mf = MessageFactory.newInstance();

        SOAPMessage message = mf.createMessage();

        MimeHeaders mh = message.getMimeHeaders();
        mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\"");
        //mh.setHeader("Content-Type", "text/xml; charset=utf-8");

        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 paraList = new HashMap();
        String datasource = xmlaConnection.getDatasource();
        paraList.put("DataSourceInfo", datasource);
        String catalog = xmlaConnection.getCatalog();
        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: " + message.toString());
        }

        return message;
    } catch (SOAPException e) {
        log.error(e);
        throw new JRRuntimeException(e);
    }
}