Example usage for javax.xml.soap SOAPConnectionFactory newInstance

List of usage examples for javax.xml.soap SOAPConnectionFactory newInstance

Introduction

In this page you can find the example usage for javax.xml.soap SOAPConnectionFactory newInstance.

Prototype

public static SOAPConnectionFactory newInstance() throws SOAPException, UnsupportedOperationException 

Source Link

Document

Creates an instance of the default SOAPConnectionFactory object.

Usage

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@SuppressWarnings("unchecked")
@Test//from w w  w. j a va 2 s .co  m
@OperateOnDeployment("orders-app")
public void testViolationsFromACMgr() {

    try {
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String orderId = "PO-19838-XYZ";

        String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                + "   <soap:Body>"
                + "       <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">"
                + "            <order>" + "                <orderId>" + orderId + "</orderId>"
                + "                <itemId>JAM</itemId>" + "                <quantity>200</quantity>"
                + "                <customer>Fred</customer>" + "            </order>"
                + "        </orders:submitOrder>" + "    </soap:Body>" + "</soap:Envelope>";

        java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes());

        SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);

        is.close();

        QuerySpec qs1 = new QuerySpec();
        qs1.setCollection(SITUATIONS);

        java.util.List<?> result0 = performACMQuery(qs1);

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        java.util.List<?> result1 = performACMQuery(qs1);

        System.out.println("RETRIEVED RESULTS 1=" + result1);

        if (result1 == null) {
            fail("Result 1 is null");
        }

        if (result1.size() - result0.size() != 2) {
            fail("2 event expected, but got: " + -result1.size() + " - " + -result0.size() + " = "
                    + (result1.size() - result0.size()));
        }

        java.util.Map<String, ?> results1 = (java.util.Map<String, ?>) result1.get(result1.size() - 1);
        java.util.Map<String, ?> results2 = (java.util.Map<String, ?>) result1.get(result1.size() - 2);

        System.out.println("RESULT1 KEYS=" + results1.keySet() + " SUBJECT=" + results1.get("subject"));
        System.out.println("RESULT2 KEYS=" + results2.keySet() + " SUBJECT=" + results2.get("subject"));

        // Check that conversation id is in the context
        java.util.List<?> contextList = null;

        if (((String) results1.get("subject")).endsWith("OrderService")) {
            contextList = (java.util.List<?>) results1.get("context");
        } else {
            contextList = (java.util.List<?>) results2.get("context");
        }

        if (contextList.size() != 3) {
            fail("Expecting 3 entries in context list: " + contextList.size());
        }

        boolean f_found = false;

        for (int i = 0; i < contextList.size(); i++) {
            java.util.Map<String, String> contextEntry = (java.util.Map<String, String>) contextList.get(i);

            if (contextEntry.containsKey("type") && contextEntry.get("type").equalsIgnoreCase("conversation")) {

                if (!contextEntry.containsKey("value")) {
                    fail("'value' property not found in context entry");
                }

                if (!contextEntry.get("value").equals(orderId)) {
                    fail("Value should be order id '" + orderId + "': " + contextEntry.get("value"));
                }

                f_found = true;
            }
        }

        if (!f_found) {
            fail("Conversation context not found");
        }

        // Check that the customer properties has been included
        java.util.Map<String, String> properties = null;

        if (((String) results1.get("subject")).endsWith("OrderService")) {
            properties = (java.util.Map<String, String>) results1.get("properties");
        } else {
            properties = (java.util.Map<String, String>) results2.get("properties");
        }

        System.err.println("PROPS=" + properties);

        // 13 properties, including the 'header' properties
        if (properties.size() != 13) {
            fail("Expecting 13 entries in property list: " + properties.size());
        }

        if (!properties.containsKey("customer")) {
            fail("Properties did not contain customer");
        }

        if (!properties.get("customer").equals("Fred")) {
            fail("Customer property not Fred: " + properties.get("customer"));
        }

    } catch (Exception e) {
        fail("Failed to invoke service: " + e);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@Test
@OperateOnDeployment("orders-app")
public void testViolationsFromSLAMonitor() {

    try {/*from   w w  w.  ja v  a 2  s  . co  m*/
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                + "   <soap:Body>"
                + "       <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">"
                + "            <order>" + "                <orderId>PO-19838-XYZ</orderId>"
                + "                <itemId>JAM</itemId>" + "                <quantity>200</quantity>"
                + "                <customer>Fred</customer>" + "            </order>"
                + "        </orders:submitOrder>" + "    </soap:Body>" + "</soap:Envelope>";

        java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes());

        SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);

        is.close();

        java.util.List<?> violationsBefore = getViolations();

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        java.util.List<?> violations = getViolations();

        if (violations == null) {
            fail("No violations returned");
        }

        System.out.println("VIOLATIONS=" + violations);

        if (violations.size() - violationsBefore.size() != 2) {
            fail("2 violation expected, but got: " + violations.size() + " - " + violationsBefore.size() + " = "
                    + (violations.size() - violationsBefore.size()));
        }

    } catch (Exception e) {
        fail("Failed to invoke service: " + e);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@Test
@OperateOnDeployment("orders-app")
public void testResponseTimesFromACMgr() {

    try {/*from www . j  ava 2s . co  m*/
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                + "   <soap:Body>"
                + "       <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">"
                + "            <order>" + "                <orderId>PO-19838-XYZ</orderId>"
                + "                <itemId>BUTTER</itemId>" + "                <quantity>200</quantity>"
                + "                <customer>Fred</customer>" + "            </order>"
                + "        </orders:submitOrder>" + "    </soap:Body>" + "</soap:Envelope>";

        java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes());

        SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);

        is.close();

        // Get base results
        QuerySpec qs1 = new QuerySpec();
        qs1.setCollection(SERVICE_RESPONSE_TIMES);

        java.util.List<?> result1base = performACMQuery(qs1);

        QuerySpec qs2 = new QuerySpec();
        qs2.setCollection("OrderService");
        qs2.setParent(SERVICE_RESPONSE_TIMES);
        qs2.setPredicate(
                new MVEL("serviceType == \"{urn:switchyard-quickstart-demo:orders:0.1.0}OrderService\" && "
                        + "operation == \"submitOrder\""));

        java.util.List<?> result2base = performACMQuery(qs2);

        // Send message
        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        java.util.List<?> result1 = performACMQuery(qs1);

        System.out.println("RETRIEVED RESULTS 1=" + result1);

        if (result1 == null) {
            fail("Result 1 is null");
        }

        if (result1.size() - result1base.size() != 3) {
            fail("3 events expected, but got: " + result1.size() + " - " + result1base.size() + " = "
                    + (result1.size() - result1base.size()));
        }

        java.util.List<?> result2 = performACMQuery(qs2);

        System.out.println("RETRIEVED RESULTS 2=" + result2);

        if (result2 == null) {
            fail("Result 2 is null");
        }

        if (result2.size() - result2base.size() != 1) {
            fail("1 event expected, but got: " + result2.size() + " - " + result2base.size() + " = "
                    + (result2.size() - result2base.size()));
        }

    } catch (Exception e) {
        fail("Failed to invoke service: " + e);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@Test
@OperateOnDeployment("orders-app")
public void testResponseTimesFromSLAMonitor() {

    try {//from  ww w . ja  v  a  2 s.  co m
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                + "   <soap:Body>"
                + "       <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">"
                + "            <order>" + "                <orderId>PO-19838-XYZ</orderId>"
                + "                <itemId>BUTTER</itemId>" + "                <quantity>200</quantity>"
                + "                <customer>Fred</customer>" + "            </order>"
                + "        </orders:submitOrder>" + "    </soap:Body>" + "</soap:Envelope>";

        java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes());

        SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);

        is.close();

        // Preload lists
        java.util.List<?> respTimes1before = getResponseTimes(null);
        java.util.List<?> respTimes2before = getResponseTimes("operation=submitOrder");

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        java.util.List<?> respTimes1 = getResponseTimes(null);

        if (respTimes1 == null) {
            fail("No events returned");
        }

        if (respTimes1.size() - respTimes1before.size() != 3) {
            fail("3 events expected, but got: " + respTimes1.size() + " - " + respTimes1before.size() + " = "
                    + (respTimes1.size() - respTimes1before.size()));
        }

        System.out.println("RESPONSE TIMES=" + respTimes1);

        // TODO: Sort out encoding to be able to pass fully qualified name of serviceType

        // {urn:switchyard-quickstart-demo:orders:0.1.0}OrderService
        java.util.List<?> respTimes2 = getResponseTimes(//"serviceType={urn%3Aswitchyard-quickstart-demo%3Aorders%3A0.1.0}OrderService&"+
                "operation=submitOrder");

        if (respTimes2 == null) {
            fail("No events returned");
        }

        if (respTimes2.size() - respTimes2before.size() != 1) {
            fail("1 event expected, but got: " + respTimes2.size() + " - " + respTimes2before.size() + " = "
                    + (respTimes2.size() - respTimes2before.size()));
        }

        System.out.println("RESPONSE TIMES (buy)=" + respTimes2);

    } catch (Exception e) {
        fail("Failed to invoke service: " + e);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@Test
@OperateOnDeployment("orders-app")
@Ignore/*from  w w  w  . j a  va 2s.  c o m*/
public void testResponseTimesOnFaultFromACMgr() {

    try {
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                + "   <soap:Body>"
                + "       <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">"
                + "            <order>" + "                <orderId>PO-19838-XYZ</orderId>"
                + "                <itemId>LAPTOP</itemId>" + "                <quantity>200</quantity>"
                + "                <customer>Fred</customer>" + "            </order>"
                + "        </orders:submitOrder>" + "    </soap:Body>" + "</soap:Envelope>";

        java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes());

        SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);

        is.close();

        // Preload results
        QuerySpec qs1 = new QuerySpec();
        qs1.setCollection(SERVICE_RESPONSE_TIMES);

        java.util.List<?> result1base = performACMQuery(qs1);

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("Item Not Available")) {
            fail("Item not available response not received");
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        java.util.List<?> result1 = performACMQuery(qs1);

        System.out.println("RETRIEVED RESULTS (Fault)=" + result1);

        if (result1 == null) {
            fail("Result 1 is null");
        }

        if (result1.size() - result1base.size() != 2) {
            fail("2 events expected, but got: " + result1.size() + " - " + result1base.size() + " = "
                    + (result1.size() - result1base.size()));
        }

    } catch (Exception e) {
        fail("Failed to invoke service: " + e);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@Test
@OperateOnDeployment("orders-app")
public void testActivityEventsProcessed() {

    EPNManager epnManager = EPNManagerAccessor.getEPNManager();

    TestListener tl = new TestListener();

    epnManager.addNotificationListener(SITUATIONS_PROCESSED, tl);

    try {/*  w w  w  .  j a  va2 s . c  o m*/
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                + "   <soap:Body>"
                + "       <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">"
                + "            <order>" + "                <orderId>PO-19838-XYZ</orderId>"
                + "                <itemId>BUTTER</itemId>" + "                <quantity>200</quantity>"
                + "                <customer>Fred</customer>" + "            </order>"
                + "        </orders:submitOrder>" + "    </soap:Body>" + "</soap:Envelope>";

        java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes());

        SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);

        is.close();

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(4000);

        if (tl.getEvents(SITUATIONS_PROCESSED) == null) {
            fail("Expecting situations processed");
        }

        // 6 instead of 3 due to the introduction of the second EPN node that also checks for SLA
        // violations, but does not generate any new situations - but this notification channel is
        // for events before they are processed.
        if (tl.getEvents(SITUATIONS_PROCESSED).size() != 6) {
            fail("Expecting 6 (sla situations) processed events, but got: "
                    + tl.getEvents(SITUATIONS_PROCESSED).size());
        }

    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to invoke service via SOAP: " + e);
    } finally {
        epnManager.removeNotificationListener(SITUATIONS_PROCESSED, tl);
    }
}

From source file:org.overlord.rtgov.tests.platforms.jbossas.slamonitor.JBossASSLAMonitorTest.java

@Test
@OperateOnDeployment("orders-app")
public void testActivityEventsResults() {

    EPNManager epnManager = EPNManagerAccessor.getEPNManager();

    TestListener tl = new TestListener();

    epnManager.addNotificationListener(SITUATIONS, tl);

    try {/*from   w  w  w  .jav  a  2s. c o m*/
        SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = factory.createConnection();

        java.net.URL url = new java.net.URL(ORDER_SERVICE_URL);

        String mesg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                + "   <soap:Body>"
                + "       <orders:submitOrder xmlns:orders=\"urn:switchyard-quickstart-demo:orders:1.0\">"
                + "            <order>" + "                <orderId>PO-13739-ABC</orderId>"
                + "                <itemId>JAM</itemId>" + "                <quantity>50</quantity>"
                + "                <customer>Fred</customer>" + "            </order>"
                + "        </orders:submitOrder>" + "    </soap:Body>" + "</soap:Envelope>";

        java.io.InputStream is = new java.io.ByteArrayInputStream(mesg.getBytes());

        SOAPMessage request = MessageFactory.newInstance().createMessage(null, is);

        is.close();

        SOAPMessage response = con.call(request, url);

        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();

        response.writeTo(baos);

        String resp = baos.toString();

        baos.close();

        if (!resp.contains("<accepted>true</accepted>")) {
            fail("Order was not accepted: " + resp);
        }

        // Wait for events to propagate
        Thread.sleep(2000);

        // Check that all events have been processed
        if (tl.getEvents(SITUATIONS) == null) {
            fail("Expecting sla violations results");
        }

        if (tl.getEvents(SITUATIONS).size() != 2) {
            fail("Expecting 2 (sla violations) results events, but got: " + tl.getEvents(SITUATIONS).size());
        }

    } catch (Exception e) {
        e.printStackTrace();
        fail("Failed to invoke service via SOAP: " + e);
    } finally {
        epnManager.removeNotificationListener(SITUATIONS, tl);
    }
}

From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java

@Override
protected boolean executeAction() {
    try {/* w  w  w  . j  a v  a  2 s .co m*/
        scf = SOAPConnectionFactory.newInstance();
        mf = MessageFactory.newInstance();
    } catch (UnsupportedOperationException e) {
        e.printStackTrace();
    } catch (SOAPException e) {
        e.printStackTrace();
    }

    String uri = this.getInputStringValue(XMLABaseComponent.URI);
    String user = this.getInputStringValue(XMLABaseComponent.USER);
    String password = this.getInputStringValue(XMLABaseComponent.PASSWORD);
    String catalog = this.getInputStringValue(XMLABaseComponent.CATALOG);
    String query = this.getInputStringValue(XMLABaseComponent.QUERY);

    buildURl(uri, user, password);
    try {
        setProviderAndDataSource(discoverDS());
        return executeQuery(query, catalog);
    } catch (XMLAException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return false;
}

From source file:org.sakaiproject.compilatio.util.CompilatioAPIUtil.java

public static Document callCompilatioReturnDocument(String apiURL, Map<String, String> parameters,
        String secretKey, final int timeout) throws TransientSubmissionException, SubmissionException {

    SOAPConnectionFactory soapConnectionFactory;
    Document xmlDocument = null;/*from   w  w  w .  jav a 2s.com*/
    try {
        soapConnectionFactory = SOAPConnectionFactory.newInstance();

        SOAPConnection soapConnection = soapConnectionFactory.createConnection();

        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();
        SOAPBody soapBody = envelope.getBody();
        SOAPElement soapBodyAction = soapBody.addChildElement(parameters.get("action"));
        parameters.remove("action");
        // api key
        SOAPElement soapBodyKey = soapBodyAction.addChildElement("key");
        soapBodyKey.addTextNode(secretKey);

        Set<Entry<String, String>> ets = parameters.entrySet();
        Iterator<Entry<String, String>> it = ets.iterator();
        while (it.hasNext()) {
            Entry<String, String> param = it.next();
            SOAPElement soapBodyElement = soapBodyAction.addChildElement(param.getKey());
            soapBodyElement.addTextNode(param.getValue());
        }

        URL endpoint = new URL(null, apiURL, new URLStreamHandler() {
            @Override
            protected URLConnection openConnection(URL url) throws IOException {
                URL target = new URL(url.toString());
                URLConnection connection = target.openConnection();
                // Connection settings
                connection.setConnectTimeout(timeout);
                connection.setReadTimeout(timeout);
                return (connection);
            }
        });

        SOAPMessage soapResponse = soapConnection.call(soapMessage, endpoint);

        // loading the XML document
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        soapResponse.writeTo(out);
        DocumentBuilderFactory builderfactory = DocumentBuilderFactory.newInstance();
        builderfactory.setNamespaceAware(true);

        DocumentBuilder builder = builderfactory.newDocumentBuilder();
        xmlDocument = builder.parse(new InputSource(new StringReader(out.toString())));
        soapConnection.close();

    } catch (UnsupportedOperationException | SOAPException | IOException | ParserConfigurationException
            | SAXException e) {
        log.error(e);
    }
    return xmlDocument;

}

From source file:org.sakaiproject.contentreview.compilatio.util.CompilatioAPIUtil.java

public static Document callCompilatioReturnDocument(String apiURL, Map<String, String> parameters,
        String secretKey, final int timeout, Proxy proxy, boolean isMultipart)
        throws TransientSubmissionException, SubmissionException {

    SOAPConnectionFactory soapConnectionFactory;
    Document xmlDocument = null;/*from   w ww  . j  av  a  2s . c om*/
    try {
        soapConnectionFactory = SOAPConnectionFactory.newInstance();

        SOAPConnection soapConnection = soapConnectionFactory.createConnection();

        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();
        SOAPBody soapBody = envelope.getBody();
        SOAPElement soapBodyAction = soapBody.addChildElement(parameters.get("action"));
        parameters.remove("action");
        // api key
        SOAPElement soapBodyKey = soapBodyAction.addChildElement("key");
        soapBodyKey.addTextNode(secretKey);

        Set<Entry<String, String>> ets = parameters.entrySet();
        Iterator<Entry<String, String>> it = ets.iterator();
        while (it.hasNext()) {
            Entry<String, String> param = it.next();
            SOAPElement soapBodyElement = soapBodyAction.addChildElement(param.getKey());
            soapBodyElement.addTextNode(param.getValue());
        }

        URL endpoint = new URL(null, apiURL, new URLStreamHandler() {
            @Override
            protected URLConnection openConnection(URL url) throws IOException {
                URL target = new URL(url.toString());
                URLConnection connection = target.openConnection();
                // Connection settings
                connection.setConnectTimeout(timeout);
                connection.setReadTimeout(timeout);
                return (connection);
            }
        });

        SOAPMessage soapResponse = soapConnection.call(soapMessage, endpoint);

        // loading the XML document
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        soapResponse.writeTo(out);
        DocumentBuilderFactory builderfactory = DocumentBuilderFactory.newInstance();
        builderfactory.setNamespaceAware(true);

        DocumentBuilder builder = builderfactory.newDocumentBuilder();
        xmlDocument = builder.parse(new InputSource(new StringReader(out.toString())));
        soapConnection.close();

    } catch (UnsupportedOperationException | SOAPException | IOException | ParserConfigurationException
            | SAXException e) {
        log.error(e);
    }
    return xmlDocument;

}