List of usage examples for javax.xml.soap SOAPConnection call
public abstract SOAPMessage call(SOAPMessage request, Object to) throws SOAPException;
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 {//from w w w . j a v a2 s.c om 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. j a v a2s . c om*/ 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
/** * Execute query//from w w w . ja v a2s. c o 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 a 2s .c o m*/ * * @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 w w w . j a va2 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 w w . j av a2s . 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; }
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/* ww w . j a va 2s.c om*/ */ 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 w w . jav a 2s . 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); } }
From source file:org.wso2.carbon.identity.provisioning.connector.UserUpdation.java
/** * Method for create SOAP connection/* www.j a v a 2s . co m*/ */ public static boolean invokeSOAP(String userId, String serviceId, String loginId, String login, String firstName, String name, String mail, String phone, String status, String role, String extraFields) throws IdentityProvisioningException { try { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); String url = InweboConnectorConstants.INWEBO_URL; SOAPMessage soapResponse = soapConnection.call(createUserObject(userId, serviceId, loginId, login, firstName, name, mail, phone, status, role, extraFields), url); String updationStatus = soapResponse.getSOAPBody().getElementsByTagName("loginUpdateReturn").item(0) .getTextContent().toString(); soapConnection.close(); 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); } 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); } }