Example usage for javax.xml.soap SOAPConnection close

List of usage examples for javax.xml.soap SOAPConnection close

Introduction

In this page you can find the example usage for javax.xml.soap SOAPConnection close.

Prototype

public abstract void close() throws SOAPException;

Source Link

Document

Closes this SOAPConnection object.

Usage

From source file:org.libreplan.importers.TimSoapClient.java

/**
 * Closes the SOAP connection/*from w  w w  .  ja va 2s  . co  m*/
 *
 * @param connection
 *            the SOAP connection
 * @throws SOAPException
 *             if unable to close connection
 */
private static void closeConnection(SOAPConnection connection) throws SOAPException {
    connection.close();
}

From source file:org.mule.modules.paypal.util.PayPalAPIHelper.java

public static void getPalDetails(@NotNull String url, @NotNull String username, @NotNull String password,
        @NotNull String appId, String signature) throws Exception {
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection = soapConnectionFactory.createConnection();
    // Send SOAP Message to SOAP Server
    SOAPMessage soapResponse;/*from  w w  w.  j  a v a 2  s .c o  m*/
    try {
        soapResponse = soapConnection.call(createGetPalDetailsSOAPRequest(username, password, appId, signature),
                url);
    } catch (Exception e) {
        throw new org.mule.api.ConnectionException(ConnectionExceptionCode.UNKNOWN_HOST, "",
                "PayPal SOAP Endpoint not reachable.", e);
    }
    if (soapResponse.getSOAPBody().hasFault()) {
        Exception e = processException(soapResponse);
        throw e;
    }
    NodeList palList = soapResponse.getSOAPBody().getElementsByTagName("Pal");
    if (palList == null || (palList != null && palList.getLength() == 0)) {
        Exception e = processException(soapResponse);
        throw e;
    }
    String pal = soapResponse.getSOAPBody().getElementsByTagName("Pal").item(0).getTextContent();
    if (StringUtils.isEmpty(pal)) {
        Exception e = processException(soapResponse);
        throw e;
    }
    soapConnection.close();
}

From source file:org.openhie.test.xds.util.SoapMessageSender.java

public static void main(String args[]) throws Exception {
    SoapMessageSender test = new SoapMessageSender();

    // Create SOAP Connection
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection = soapConnectionFactory.createConnection();

    // Send SOAP Message to SOAP Server
    String url = "http://iol.test.ohie.org:5001/xdsrepository";
    SOAPMessage so = test.getSoapMessageFromString();
    SOAPHeader header = so.getSOAPHeader();

    log.info(soapConnection.call(test.getSoapMessageFromString(), url));

    // print SOAP Response
    System.out.print("Response SOAP Message:");
    //soapResponse.writeTo(System.out);

    soapConnection.close();
}

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

/**
 * Execute query/*from w  w  w . ja v a 2s  .co  m*/
 *
 * @param query   - MDX to be executed
 * @param catalog
 * @param handler Callback handler
 * @throws XMLAException
 */
public boolean executeQuery(final String query, final String catalog) throws XMLAException {

    Object[][] columnHeaders = null;
    Object[][] rowHeaders = null;
    Object[][] data = null;

    int columnCount = 0;
    int rowCount = 0;

    SOAPConnection connection = null;
    SOAPMessage reply = null;

    try {
        connection = scf.createConnection();
        SOAPMessage msg = mf.createMessage();

        MimeHeaders mh = msg.getMimeHeaders();
        mh.setHeader("SOAPAction", XMLABaseComponent.EXECUTE_ACTION); //$NON-NLS-1$

        SOAPPart soapPart = msg.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();
        envelope.setEncodingStyle(XMLABaseComponent.ENCODING_STYLE);

        SOAPBody body = envelope.getBody();
        Name nEx = envelope.createName("Execute", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$//$NON-NLS-2$

        SOAPElement eEx = body.addChildElement(nEx);
        eEx.setEncodingStyle(XMLABaseComponent.ENCODING_STYLE);

        // add the parameters

        // COMMAND parameter
        // <Command>
        // <Statement>select [Measures].members on Columns from
        // Sales</Statement>
        // </Command>
        Name nCom = envelope.createName("Command", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$ //$NON-NLS-2$
        SOAPElement eCommand = eEx.addChildElement(nCom);
        Name nSta = envelope.createName("Statement", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$ //$NON-NLS-2$
        SOAPElement eStatement = eCommand.addChildElement(nSta);
        eStatement.addTextNode(query);

        // <Properties>
        // <PropertyList>
        // <DataSourceInfo>Provider=MSOLAP;Data
        // Source=local</DataSourceInfo>
        // <Catalog>Foodmart 2000</Catalog>
        // <Format>Multidimensional</Format>
        // <AxisFormat>TupleFormat</AxisFormat> oder "ClusterFormat"
        // </PropertyList>
        // </Properties>
        Map paraList = new HashMap();
        paraList.put("DataSourceInfo", dataSource); //$NON-NLS-1$
        paraList.put("Catalog", catalog); //$NON-NLS-1$
        paraList.put("Format", "Multidimensional"); //$NON-NLS-1$ //$NON-NLS-2$
        paraList.put("AxisFormat", "TupleFormat"); //$NON-NLS-1$ //$NON-NLS-2$
        addParameterList(envelope, eEx, "Properties", "PropertyList", paraList); //$NON-NLS-1$ //$NON-NLS-2$

        msg.saveChanges();

        debug("Request for Execute"); //$NON-NLS-1$
        logSoapMsg(msg);

        // run the call
        reply = connection.call(msg, url);

        debug("Reply from Execute"); //$NON-NLS-1$
        logSoapMsg(reply);

        // error check
        errorCheck(reply);

        // process the reply
        SOAPElement eRoot = findExecRoot(reply);

        // for each axis, get the positions (tuples)
        Name name = envelope.createName("Axes", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$ //$NON-NLS-2$
        SOAPElement eAxes = selectSingleNode(eRoot, name);
        if (eAxes == null) {
            throw new XMLAException("Excecute result has no Axes element"); //$NON-NLS-1$
        }

        name = envelope.createName("Axis", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$ //$NON-NLS-2$
        Iterator itAxis = eAxes.getChildElements(name);

        AxisLoop: for (int iOrdinal = 0; itAxis.hasNext();) {
            SOAPElement eAxis = (SOAPElement) itAxis.next();
            name = envelope.createName("name"); //$NON-NLS-1$
            String axisName = eAxis.getAttributeValue(name);
            int axisOrdinal;
            if (axisName.equals("SlicerAxis")) { //$NON-NLS-1$
                continue;
            } else {
                axisOrdinal = iOrdinal++;
            }

            name = envelope.createName("Tuples", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$
            SOAPElement eTuples = selectSingleNode(eAxis, name);
            if (eTuples == null) {
                continue AxisLoop; // what else?
            }

            name = envelope.createName("Tuple", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$
            Iterator itTuple = eTuples.getChildElements(name);

            // loop over tuples
            int positionOrdinal = 0;
            while (itTuple.hasNext()) { // TupleLoop

                SOAPElement eTuple = (SOAPElement) itTuple.next();

                if ((axisOrdinal == XMLABaseComponent.AXIS_COLUMNS) && (columnHeaders == null)) {
                    columnCount = getChildCount(envelope, eTuples, "Tuple"); //$NON-NLS-1$
                    columnHeaders = new Object[getChildCount(envelope, eTuple, "Member")][columnCount]; //$NON-NLS-1$
                } else if ((axisOrdinal == XMLABaseComponent.AXIS_ROWS) && (rowHeaders == null)) {
                    rowCount = getChildCount(envelope, eTuples, "Tuple"); //$NON-NLS-1$
                    rowHeaders = new Object[rowCount][getChildCount(envelope, eTuple, "Member")]; //$NON-NLS-1$
                }

                int index = 0;
                name = envelope.createName("Member", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$
                Iterator itMember = eTuple.getChildElements(name);
                while (itMember.hasNext()) { // MemberLoop
                    SOAPElement eMem = (SOAPElement) itMember.next();
                    // loop over children nodes
                    String caption = null;
                    Iterator it = eMem.getChildElements();
                    InnerLoop: while (it.hasNext()) {
                        Node n = (Node) it.next();
                        if (!(n instanceof SOAPElement)) {
                            continue InnerLoop;
                        }
                        SOAPElement el = (SOAPElement) n;
                        String enam = el.getElementName().getLocalName();
                        if (enam.equals("Caption")) { //$NON-NLS-1$
                            caption = el.getValue();
                        }
                    }
                    if (axisOrdinal == XMLABaseComponent.AXIS_COLUMNS) {
                        columnHeaders[index][positionOrdinal] = caption;
                    } else if (axisOrdinal == XMLABaseComponent.AXIS_ROWS) {
                        rowHeaders[positionOrdinal][index] = caption;
                    }
                    ++index;
                } // MemberLoop

                ++positionOrdinal;
            } // TupleLoop
        } // AxisLoop

        data = new Object[rowCount][columnCount];
        // loop over cells in result set
        name = envelope.createName("CellData", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$
        SOAPElement eCellData = selectSingleNode(eRoot, name);
        name = envelope.createName("Cell", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$
        Iterator itSoapCell = eCellData.getChildElements(name);
        while (itSoapCell.hasNext()) { // CellLoop
            SOAPElement eCell = (SOAPElement) itSoapCell.next();
            name = envelope.createName("CellOrdinal", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            String cellOrdinal = eCell.getAttributeValue(name);
            int ordinal = Integer.parseInt(cellOrdinal);
            name = envelope.createName("Value", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$
            Object value = selectSingleNode(eCell, name).getValue();

            int rowLoc = ordinal / columnCount;
            int columnLoc = ordinal % columnCount;

            data[rowLoc][columnLoc] = value;
        } // CellLoop

        MemoryResultSet resultSet = new MemoryResultSet();
        MemoryMetaData metaData = new MemoryMetaData(columnHeaders, rowHeaders);
        resultSet.setMetaData(metaData);
        for (Object[] element : data) {
            resultSet.addRow(element);
        }
        rSet = resultSet;
        if (resultSet != null) {
            if (getResultOutputName() != null) {
                setOutputValue(getResultOutputName(), resultSet);
            }
            return true;
        }
        return false;

    } catch (SOAPException se) {
        throw new XMLAException(se);
    } finally {
        if (connection != null) {
            try {
                connection.close();
            } catch (SOAPException e) {
                // log and ignore
                error("?", e); //$NON-NLS-1$
            }
        }

    }

}

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

/**
 * discover// ww  w . ja  v  a2 s  . c om
 *
 * @param request
 * @param discoverUrl
 * @param restrictions
 * @param properties
 * @param rh
 * @throws XMLAException
 */
private void discover(final String request, final URL discoverUrl, final Map restrictions, final Map properties,
        final Rowhandler rh) throws XMLAException {

    try {
        SOAPConnection connection = scf.createConnection();

        SOAPMessage msg = mf.createMessage();

        MimeHeaders mh = msg.getMimeHeaders();
        mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Discover\""); //$NON-NLS-1$ //$NON-NLS-2$

        SOAPPart soapPart = msg.getSOAPPart();
        SOAPEnvelope envelope = soapPart.getEnvelope();
        envelope.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); //$NON-NLS-1$//$NON-NLS-2$
        envelope.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$ //$NON-NLS-2$
        SOAPBody body = envelope.getBody();
        Name nDiscover = envelope.createName("Discover", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$//$NON-NLS-2$

        SOAPElement eDiscover = body.addChildElement(nDiscover);
        eDiscover.setEncodingStyle(XMLABaseComponent.ENCODING_STYLE);

        Name nPara = envelope.createName("RequestType", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$//$NON-NLS-2$
        SOAPElement eRequestType = eDiscover.addChildElement(nPara);
        eRequestType.addTextNode(request);

        // add the parameters
        if (restrictions != null) {
            addParameterList(envelope, eDiscover, "Restrictions", "RestrictionList", restrictions); //$NON-NLS-1$ //$NON-NLS-2$
        }
        addParameterList(envelope, eDiscover, "Properties", "PropertyList", properties); //$NON-NLS-1$//$NON-NLS-2$

        msg.saveChanges();

        debug(Messages.getInstance().getString("XMLABaseComponent.DEBUG_0006_DISCOVER_REQUEST") + request); //$NON-NLS-1$
        logSoapMsg(msg);

        // run the call
        SOAPMessage reply = connection.call(msg, discoverUrl);

        debug(Messages.getInstance().getString("XMLABaseComponent.DEBUG_0007_DISCOVER_RESPONSE") + request); //$NON-NLS-1$
        logSoapMsg(reply);

        errorCheck(reply);

        SOAPElement eRoot = findDiscoverRoot(reply);

        Name nRow = envelope.createName("row", "", XMLABaseComponent.ROWS_URI); //$NON-NLS-1$ //$NON-NLS-2$
        Iterator itRow = eRoot.getChildElements(nRow);
        while (itRow.hasNext()) { // RowLoop

            SOAPElement eRow = (SOAPElement) itRow.next();
            rh.handleRow(eRow, envelope);

        } // RowLoop

        connection.close();
    } catch (UnsupportedOperationException e) {
        throw new XMLAException(e);
    } catch (SOAPException e) {
        throw new XMLAException(e);
    }

}

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  ww  w  .  ja  va 2  s  . 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;//  w ww . j ava 2s . c o  m
    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.wso2.carbon.identity.provisioning.connector.InweboUserManager.java

/**
 * Method to create SOAP connection/*from w w w.j  a v  a 2 s. co  m*/
 */
public static String invokeSOAP(InweboUser user, String operation) throws IdentityProvisioningException {
    String provisionedId = null;
    SOAPConnectionFactory soapConnectionFactory = null;
    SOAPConnection soapConnection = null;
    try {
        Properties inweboProperties = new Properties();
        String resourceName = InweboConnectorConstants.PROPERTIES_FILE;
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream resourceStream = loader.getResourceAsStream(resourceName);
        try {
            inweboProperties.load(resourceStream);
        } catch (IOException e) {
            throw new IdentityProvisioningException("Unable to load the properties file", e);
        }

        SOAPMessage soapMessage = null;
        soapConnectionFactory = SOAPConnectionFactory.newInstance();
        soapConnection = soapConnectionFactory.createConnection();
        String url = inweboProperties.getProperty(InweboConnectorConstants.INWEBO_URL);
        if (operation.equals(InweboConnectorConstants.INWEBO_OPERATION_POST)) {
            soapMessage = createUserSOAPMessage(inweboProperties, user);
        } else if (operation.equals(InweboConnectorConstants.INWEBO_OPERATION_PUT)) {
            soapMessage = updateUserSOAPMessage(inweboProperties, user);
        } else if (operation.equals(InweboConnectorConstants.INWEBO_OPERATION_DELETE)) {
            soapMessage = deleteUserSOAPMessage(inweboProperties, user.getLoginId(), user.getUserId(),
                    user.getServiceId());
        }
        SOAPMessage soapResponse = soapConnection.call(soapMessage, url);
        if (operation.equals(InweboConnectorConstants.INWEBO_OPERATION_POST)) {
            if (soapResponse.getSOAPBody().getElementsByTagName("id").getLength() != 0) {
                provisionedId = soapResponse.getSOAPBody().getElementsByTagName("id").item(0).getTextContent()
                        .toString();
                if (StringUtils.isEmpty(provisionedId) || "0".equals(provisionedId)) {
                    String error = soapResponse.getSOAPBody().getElementsByTagName("loginCreateReturn").item(0)
                            .getTextContent().toString();
                    throw new IdentityProvisioningException(
                            "Error occurred while creating the user in InWebo:" + error);
                }
            } else {
                throw new IdentityProvisioningException("Unable to find the provisioning ID");
            }
        } else if (operation.equals(InweboConnectorConstants.INWEBO_OPERATION_PUT)) {
            if (soapResponse.getSOAPBody().getElementsByTagName("loginUpdateReturn").getLength() != 0) {
                String updationStatus = soapResponse.getSOAPBody().getElementsByTagName("loginUpdateReturn")
                        .item(0).getTextContent().toString();
                boolean processStatus = StringUtils.equals("OK", updationStatus);
                if (!processStatus) {
                    String error = soapResponse.getSOAPBody().getElementsByTagName("loginUpdateReturn").item(0)
                            .getTextContent().toString();
                    throw new IdentityProvisioningException(
                            "Error occurred while updating the user in InWebo:" + error);
                }
            } else {
                throw new IdentityProvisioningException("Unable to get the updation status");
            }
        } else if (operation.equals(InweboConnectorConstants.INWEBO_OPERATION_DELETE)) {
            if (soapResponse.getSOAPBody().getElementsByTagName("loginDeleteReturn").getLength() != 0) {
                String deletionStatus = soapResponse.getSOAPBody().getElementsByTagName("loginDeleteReturn")
                        .item(0).getTextContent().toString();
                boolean processStatus = StringUtils.equals("OK", deletionStatus);
                if (!processStatus) {
                    String error = soapResponse.getSOAPBody().getElementsByTagName("loginDeleteReturn").item(0)
                            .getTextContent().toString();
                    throw new IdentityProvisioningException(
                            "Error occurred while deleting the user from InWebo:" + error);
                }
            } else {
                throw new IdentityProvisioningException("Unable to get the operation status");
            }
        }
    } catch (SOAPException e) {
        throw new IdentityProvisioningException("Error occurred while sending SOAP Request to Server", e);
    } finally {
        try {
            if (soapConnection != null) {
                soapConnection.close();
            }
        } catch (SOAPException e) {
            log.error("Error while closing the SOAP connection", e);
        }
    }
    return provisionedId;
}

From source file:org.wso2.carbon.identity.provisioning.connector.UserCreation.java

/**
 * Method for create SOAP connection/*from  w  ww  . j a  va2 s  . co  m*/
 */
public static String invokeSOAP(String userId, String serviceId, String login, String firstName, String name,
        String mail, String phone, String status, String role, String access, String codeType, String language,
        String extraFields) throws IdentityProvisioningException {
    String provisionedId = null;
    try {
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = soapConnectionFactory.createConnection();
        String url = InweboConnectorConstants.INWEBO_URL;
        SOAPMessage soapResponse = soapConnection.call(createUser(userId, serviceId, login, firstName, name,
                mail, phone, status, role, access, codeType, language, extraFields), url);
        provisionedId = soapResponse.getSOAPBody().getElementsByTagName("id").item(0).getTextContent()
                .toString();
        soapConnection.close();
        if (StringUtils.isEmpty(provisionedId) || provisionedId.equals("0")) {
            String error = soapResponse.getSOAPBody().getElementsByTagName("loginCreateReturn").item(0)
                    .getTextContent().toString();
            throw new IdentityProvisioningException(
                    "Error occurred while creating the user in InWebo:" + error);
        }
    } catch (SOAPException e) {
        throw new IdentityProvisioningException("Error occurred while sending SOAP Request to Server", e);
    } catch (IdentityProvisioningException e) {
        throw new IdentityProvisioningException("Error occurred while sending SOAP Request to Server", e);
    }
    return provisionedId;
}

From source file:org.wso2.carbon.identity.provisioning.connector.UserDeletion.java

public boolean deleteUser(String loginId, String userId, String serviceId)
        throws IdentityProvisioningException {
    try {/*from  w  ww .  ja  va2  s  .  c  om*/
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = soapConnectionFactory.createConnection();
        String url = InweboConnectorConstants.INWEBO_URL;
        SOAPMessage soapResponse = soapConnection.call(deleteUsers(loginId, userId, serviceId), url);
        String deletionStatus = soapResponse.getSOAPBody().getElementsByTagName("loginDeleteReturn").item(0)
                .getTextContent().toString();
        soapConnection.close();
        boolean processStatus = StringUtils.equals("OK", deletionStatus);
        if (!processStatus) {
            String error = soapResponse.getSOAPBody().getElementsByTagName("loginDeleteReturn").item(0)
                    .getTextContent().toString();
            throw new IdentityProvisioningException(
                    "Error occurred while deleting the user from InWebo:" + error);
        }
        return processStatus;
    } catch (SOAPException e) {
        throw new IdentityProvisioningException("Error occurred while sending SOAP Request to Server", e);
    } catch (IdentityProvisioningException e) {
        throw new IdentityProvisioningException("Error occurred while sending SOAP Request to Server", e);
    }
}