List of usage examples for javax.xml.soap SOAPMessage getSOAPPart
public abstract SOAPPart getSOAPPart();
From source file:org.springframework.integration.sqs.AWSSecurityHandler.java
/** * {@inheritDoc}/*from w w w. j a v a 2 s. co m*/ */ public boolean handleMessage(final SOAPMessageContext context) { logMessage(context); Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outboundProperty) { return true; } /* * Example SOAP header from * http://docs.amazonwebservices.com/AWSSimpleQueueService * /2008-01-01/SQSDeveloperGuide * /MakingRequests_MakingSOAPRequestsArticle.html * * <soapenv:Header * xmlns:aws="http://security.amazonaws.com/doc/2007-01-01/"> * <aws:AWSAccessKeyId>1D9FVRAYCP1VJS767E02EXAMPLE</aws:AWSAccessKeyId> * <aws:Timestamp>2008-02-10T23:59:59Z</aws:Timestamp> * <aws:Signature>SZf1CHmQ/nrZbsrC13hCZS061ywsEXAMPLE</aws:Signature> * </soapenv:Header> */ SOAPMessage aSOAPMessage = context.getMessage(); try { SOAPEnvelope aEnvelope = aSOAPMessage.getSOAPPart().getEnvelope(); SOAPHeader aHeader = aEnvelope.addHeader(); String aTimestampStr = this.getTimestamp(); // ADD AWS SECURITY HEADER ---------------------------------------- aHeader.addNamespaceDeclaration(NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); // ADD ACCESS KEY ------------------------------------------------- Name aKeyName = aEnvelope.createName("AWSAccessKeyId", NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); SOAPHeaderElement aKey = aHeader.addHeaderElement(aKeyName); aKey.addTextNode(s_key); // ADD TIMESTAMP -------------------------------------------------- Name aTimestampName = aEnvelope.createName("Timestamp", NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); SOAPHeaderElement aTimestamp = aHeader.addHeaderElement(aTimestampName); aTimestamp.addTextNode(aTimestampStr); // ADD SIGNATURE -------------------------------------------------- Name aSignatureName = aEnvelope.createName("Signature", NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); SOAPHeaderElement aSignature = aHeader.addHeaderElement(aSignatureName); SOAPBody aBody = aEnvelope.getBody(); Iterator<?> aChildren = aBody.getChildElements(); SOAPBodyElement aAction = (SOAPBodyElement) aChildren.next(); if (aChildren.hasNext()) { throw new IllegalStateException( "Unexpected number of actions in soap request. Cannot calculate signature."); } aSignature.addTextNode(this.calculateSignature(aAction.getLocalName(), aTimestampStr)); aSOAPMessage.saveChanges(); logMessage("Final out message: ", aSOAPMessage); } catch (Exception e) { throw new IllegalStateException("Failed to add aws headers!", e); } return true; }
From source file:org.springframework.ws.soap.saaj.support.SaajUtils.java
/** * Gets the SAAJ version for the specified {@link SOAPMessage}. * * @return a code comparable to the SAAJ_XX codes in this class * @see #SAAJ_11/* w ww. jav a 2 s. co m*/ * @see #SAAJ_12 * @see #SAAJ_13 */ public static int getSaajVersion(SOAPMessage soapMessage) throws SOAPException { Assert.notNull(soapMessage, "'soapMessage' must not be null"); SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope(); return getSaajVersion(soapEnvelope); }
From source file:org.wso2.caching.receivers.CacheMessageReceiver.java
/** * This method will be called when the message is received to the MR * and this will serve the response from the cache * * @param messageCtx - MessageContext to be served * @throws AxisFault if there is any error in serving from the cache *//*from w w w .ja v a 2s . co m*/ public void receive(MessageContext messageCtx) throws AxisFault { MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(messageCtx); if (outMsgContext != null) { OperationContext opCtx = outMsgContext.getOperationContext(); if (opCtx != null) { opCtx.addMessageContext(outMsgContext); if (log.isDebugEnabled()) { log.debug("Serving from the cache..."); } Object cachedObj = opCtx.getPropertyNonReplicable(CachingConstants.CACHED_OBJECT); if (cachedObj != null && cachedObj instanceof CachableResponse) { try { MessageFactory mf = MessageFactory.newInstance(); SOAPMessage smsg; if (messageCtx.isSOAP11()) { smsg = mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(((CachableResponse) cachedObj).getResponseEnvelope())); ((CachableResponse) cachedObj).setInUse(false); } else { MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addHeader("Content-ID", IDGenerator.generateID()); mimeHeaders.addHeader("content-type", HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML); smsg = mf.createMessage(mimeHeaders, new ByteArrayInputStream(((CachableResponse) cachedObj).getResponseEnvelope())); ((CachableResponse) cachedObj).setInUse(false); } if (smsg != null) { org.apache.axiom.soap.SOAPEnvelope omSOAPEnv = SAAJUtil .toOMSOAPEnvelope(smsg.getSOAPPart().getDocumentElement()); if (omSOAPEnv.getHeader() == null) { SOAPFactory fac = getSOAPFactory(messageCtx); fac.createSOAPHeader(omSOAPEnv); } outMsgContext.setEnvelope(omSOAPEnv); } else { handleException("Unable to serve from the cache : " + "Couldn't build the SOAP response from the cached byte stream"); } } catch (SOAPException e) { handleException("Unable to serve from the cache : " + "Unable to get build the response from the byte stream", e); } catch (IOException e) { handleException("Unable to serve from the cache : " + "I/O Error in building the response envelope from the byte stream"); } AxisEngine.send(outMsgContext); } else { handleException("Unable to find the response in the cache"); } } else { handleException("Unable to serve from " + "the cache : OperationContext not found for processing"); } } else { handleException("Unable to serve from " + "the cache : Unable to get the out message context"); } }
From source file:org.wso2.carbon.caching.module.receivers.CacheMessageReceiver.java
/** * This method will be called when the message is received to the MR * and this will serve the response from the cache * * @param messageCtx - MessageContext to be served * @throws AxisFault if there is any error in serving from the cache *//*from w w w .j a va 2s . com*/ public void receive(MessageContext messageCtx) throws AxisFault { MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(messageCtx); if (outMsgContext != null) { OperationContext opCtx = outMsgContext.getOperationContext(); if (opCtx != null) { opCtx.addMessageContext(outMsgContext); if (log.isDebugEnabled()) { log.debug("Serving from the cache..."); } Object cachedObj = opCtx.getPropertyNonReplicable(CachingConstants.CACHED_OBJECT); /** * This was introduced to avoid cache being expired before this below code executed. */ byte[] bt = (byte[]) opCtx.getPropertyNonReplicable(CachingConstants.CACHEENVELOPE); if (bt != null) { try { MessageFactory mf = MessageFactory.newInstance(); SOAPMessage smsg; if (messageCtx.isSOAP11()) { smsg = mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(bt)); ((CachableResponse) cachedObj).setInUse(false); } else { MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addHeader("Content-ID", IDGenerator.generateID()); mimeHeaders.addHeader("content-type", HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML); smsg = mf.createMessage(mimeHeaders, new ByteArrayInputStream(bt)); ((CachableResponse) cachedObj).setInUse(false); } if (smsg != null) { org.apache.axiom.soap.SOAPEnvelope omSOAPEnv = SAAJUtil .toOMSOAPEnvelope(smsg.getSOAPPart().getDocumentElement()); if (omSOAPEnv.getHeader() == null) { SOAPFactory fac = getSOAPFactory(messageCtx); fac.createSOAPHeader(omSOAPEnv); } outMsgContext.setEnvelope(omSOAPEnv); } else { handleException("Unable to serve from the cache : " + "Couldn't build the SOAP response from the cached byte stream"); } } catch (SOAPException e) { handleException("Unable to serve from the cache : " + "Unable to get build the response from the byte stream", e); } catch (IOException e) { handleException("Unable to serve from the cache : " + "I/O Error in building the response envelope from the byte stream"); } AxisEngine.send(outMsgContext); } else { handleException("Unable to find the response in the cache"); } } else { handleException("Unable to serve from " + "the cache : OperationContext not found for processing"); } } else { handleException("Unable to serve from " + "the cache : Unable to get the out message context"); } }
From source file:org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment.util.MessageHandler.java
/** * This method adds Timestamp for SOAP header, and adds Content-length for HTTP header for * avoiding HTTP chunking.//from ww w . j a v a 2 s. c o m * * @param context - Context of the SOAP Message */ @Override public boolean handleMessage(SOAPMessageContext context) { Boolean outBoundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outBoundProperty) { SOAPMessage message = context.getMessage(); SOAPHeader header = null; SOAPEnvelope envelope = null; try { header = message.getSOAPHeader(); envelope = message.getSOAPPart().getEnvelope(); } catch (SOAPException e) { Response.serverError().entity("SOAP message content cannot be read.").build(); } try { if ((header == null) && (envelope != null)) { header = envelope.addHeader(); } } catch (SOAPException e) { Response.serverError().entity("SOAP header cannot be added.").build(); } SOAPFactory soapFactory = null; try { soapFactory = SOAPFactory.newInstance(); } catch (SOAPException e) { Response.serverError().entity("Cannot get an instance of SOAP factory.").build(); } QName qNamesSecurity = new QName(PluginConstants.WS_SECURITY_TARGET_NAMESPACE, PluginConstants.CertificateEnrolment.SECURITY); SOAPHeaderElement Security = null; Name attributeName = null; try { if (header != null) { Security = header.addHeaderElement(qNamesSecurity); } if (soapFactory != null) { attributeName = soapFactory.createName(PluginConstants.CertificateEnrolment.TIMESTAMP_ID, PluginConstants.CertificateEnrolment.TIMESTAMP_U, PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY); } } catch (SOAPException e) { Response.serverError().entity("Security header cannot be added.").build(); } QName qNameTimestamp = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY, PluginConstants.CertificateEnrolment.TIMESTAMP); SOAPHeaderElement timestamp = null; try { if (header != null) { timestamp = header.addHeaderElement(qNameTimestamp); timestamp.addAttribute(attributeName, PluginConstants.CertificateEnrolment.TIMESTAMP_0); } } catch (SOAPException e) { Response.serverError().entity("Exception while adding timestamp header.").build(); } DateTime dateTime = new DateTime(); DateTime expiredDateTime = dateTime.plusMinutes(VALIDITY_TIME); String createdISOTime = dateTime.toString(ISODateTimeFormat.dateTime()); String expiredISOTime = expiredDateTime.toString(ISODateTimeFormat.dateTime()); createdISOTime = createdISOTime.substring(TIMESTAMP_BEGIN_INDEX, createdISOTime.length() - TIMESTAMP_END_INDEX); createdISOTime = createdISOTime + TIME_ZONE; expiredISOTime = expiredISOTime.substring(TIMESTAMP_BEGIN_INDEX, expiredISOTime.length() - TIMESTAMP_END_INDEX); expiredISOTime = expiredISOTime + TIME_ZONE; QName qNameCreated = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY, PluginConstants.CertificateEnrolment.CREATED); SOAPHeaderElement SOAPHeaderCreated = null; try { if (header != null) { SOAPHeaderCreated = header.addHeaderElement(qNameCreated); SOAPHeaderCreated.addTextNode(createdISOTime); } } catch (SOAPException e) { Response.serverError().entity("Exception while creating SOAP header.").build(); } QName qNameExpires = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY, PluginConstants.CertificateEnrolment.EXPIRES); SOAPHeaderElement SOAPHeaderExpires = null; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); String messageString = null; try { if (header != null) { SOAPHeaderExpires = header.addHeaderElement(qNameExpires); SOAPHeaderExpires.addTextNode(expiredISOTime); } if ((timestamp != null) && (Security != null)) { timestamp.addChildElement(SOAPHeaderCreated); timestamp.addChildElement(SOAPHeaderExpires); Security.addChildElement(timestamp); } message.saveChanges(); message.writeTo(outputStream); messageString = new String(outputStream.toByteArray(), PluginConstants.CertificateEnrolment.UTF_8); } catch (SOAPException e) { Response.serverError().entity("Exception while creating timestamp SOAP header.").build(); } catch (IOException e) { Response.serverError().entity("Exception while writing message to output stream.").build(); } Map<String, List<String>> headers = (Map<String, List<String>>) context .get(MessageContext.HTTP_REQUEST_HEADERS); headers = new HashMap<String, List<String>>(); if (messageString != null) { headers.put(PluginConstants.CONTENT_LENGTH, Arrays.asList(String.valueOf(messageString.length()))); } context.put(MessageContext.HTTP_REQUEST_HEADERS, headers); } return true; }
From source file:org.wso2.carbon.identity.provisioning.connector.InweboUserManager.java
private static SOAPMessage createUserSOAPMessage(Properties inweboProperties, InweboUser user) throws SOAPException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = inweboProperties.getProperty(InweboConnectorConstants.INWEBO_URI); SOAPEnvelope envelope = soapPart.getEnvelope(); String namespacePrefix = InweboConnectorConstants.SOAPMessage.SOAP_NAMESPACE_PREFIX; envelope.addNamespaceDeclaration(namespacePrefix, serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACTION_LOGIN_CREATE, namespacePrefix); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_USER_ID, namespacePrefix);//from w w w .ja v a 2 s . c om soapBodyElem1.addTextNode(user.getUserId()); SOAPElement soapBodyElem2 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_SERVICE_ID, namespacePrefix); soapBodyElem2.addTextNode(user.getServiceId()); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN, namespacePrefix); soapBodyElem3.addTextNode(user.getLogin()); SOAPElement soapBodyElem4 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_FIRST_NAME, namespacePrefix); soapBodyElem4.addTextNode(user.getFirstName()); SOAPElement soapBodyElem5 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_NAME, namespacePrefix); soapBodyElem5.addTextNode(user.getLastName()); SOAPElement soapBodyElem6 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_MAIL, namespacePrefix); soapBodyElem6.addTextNode(user.getMail()); SOAPElement soapBodyElem7 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_PHONE, namespacePrefix); soapBodyElem7.addTextNode(user.getPhone()); SOAPElement soapBodyElem8 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_STATUS, namespacePrefix); soapBodyElem8.addTextNode(user.getStatus()); SOAPElement soapBodyElem9 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ROLE, namespacePrefix); soapBodyElem9.addTextNode(user.getRole()); SOAPElement soapBodyElem10 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACCESS, namespacePrefix); soapBodyElem10.addTextNode(user.getAccess()); SOAPElement soapBodyElem11 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_CONTENT_TYPE, namespacePrefix); soapBodyElem11.addTextNode(user.getCodeType()); SOAPElement soapBodyElem12 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LANG, namespacePrefix); soapBodyElem12.addTextNode(user.getLanguage()); SOAPElement soapBodyElem13 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_EXTRA_FIELDS, namespacePrefix); soapBodyElem13.addTextNode(user.getExtraFields()); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader(InweboConnectorConstants.SOAPMessage.SOAP_ACTION, serverURI + InweboConnectorConstants.SOAPMessage.SOAP_ACTION_HEADER); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.InweboUserManager.java
private static SOAPMessage updateUserSOAPMessage(Properties inweboProperties, InweboUser user) throws SOAPException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = inweboProperties.getProperty(InweboConnectorConstants.INWEBO_URI); SOAPEnvelope envelope = soapPart.getEnvelope(); String namespacePrefix = InweboConnectorConstants.SOAPMessage.SOAP_NAMESPACE_PREFIX; envelope.addNamespaceDeclaration(namespacePrefix, serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACTION_LOGIN_UPDATE, namespacePrefix); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_USER_ID, namespacePrefix);//ww w . ja v a 2 s . c om soapBodyElem1.addTextNode(user.getUserId()); SOAPElement soapBodyElem2 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_SERVICE_ID, namespacePrefix); soapBodyElem2.addTextNode(user.getServiceId()); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN_ID, namespacePrefix); soapBodyElem3.addTextNode(user.getLoginId()); SOAPElement soapBodyElem4 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN, namespacePrefix); soapBodyElem4.addTextNode(user.getLogin()); SOAPElement soapBodyElem5 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_FIRST_NAME, namespacePrefix); soapBodyElem5.addTextNode(user.getFirstName()); SOAPElement soapBodyElem6 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_NAME, namespacePrefix); soapBodyElem6.addTextNode(user.getLastName()); SOAPElement soapBodyElem7 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_MAIL, namespacePrefix); soapBodyElem7.addTextNode(user.getMail()); SOAPElement soapBodyElem8 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_PHONE, namespacePrefix); soapBodyElem8.addTextNode(user.getPhone()); SOAPElement soapBodyElem9 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_STATUS, namespacePrefix); soapBodyElem9.addTextNode(user.getStatus()); SOAPElement soapBodyElem10 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ROLE, namespacePrefix); soapBodyElem10.addTextNode(user.getRole()); SOAPElement soapBodyElem11 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_EXTRA_FIELDS, namespacePrefix); soapBodyElem11.addTextNode(user.getExtraFields()); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader(InweboConnectorConstants.SOAPMessage.SOAP_ACTION, serverURI + InweboConnectorConstants.SOAPMessage.SOAP_ACTION_HEADER); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.InweboUserManager.java
private static SOAPMessage deleteUserSOAPMessage(Properties inweboProperties, String loginId, String userId, String serviceId) throws SOAPException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = inweboProperties.getProperty(InweboConnectorConstants.INWEBO_URI); SOAPEnvelope envelope = soapPart.getEnvelope(); String namespacePrefix = InweboConnectorConstants.SOAPMessage.SOAP_NAMESPACE_PREFIX; envelope.addNamespaceDeclaration(namespacePrefix, serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACTION_LOGIN_DELETE, namespacePrefix); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_USER_ID, namespacePrefix);// w w w. j ava 2 s . c o m soapBodyElem1.addTextNode(userId); SOAPElement soapBodyElem2 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_SERVICE_ID, namespacePrefix); soapBodyElem2.addTextNode(serviceId); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN_ID, namespacePrefix); soapBodyElem3.addTextNode(loginId); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader(InweboConnectorConstants.SOAPMessage.SOAP_ACTION, serverURI + InweboConnectorConstants.SOAPMessage.SOAP_ACTION_HEADER); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.UserCreation.java
private static SOAPMessage createUser(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 SOAPException, IdentityProvisioningException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = InweboConnectorConstants.INWEBO_URI; SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("con", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("loginCreate", "con"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("userid", "con"); soapBodyElem1.addTextNode(userId);/* w w w .j a va 2s. co m*/ SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("serviceid", "con"); soapBodyElem2.addTextNode(serviceId); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("login", "con"); soapBodyElem3.addTextNode(login); SOAPElement soapBodyElem4 = soapBodyElem.addChildElement("firstname", "con"); soapBodyElem4.addTextNode(firstName); SOAPElement soapBodyElem5 = soapBodyElem.addChildElement("name", "con"); soapBodyElem5.addTextNode(name); SOAPElement soapBodyElem6 = soapBodyElem.addChildElement("mail", "con"); soapBodyElem6.addTextNode(mail); SOAPElement soapBodyElem7 = soapBodyElem.addChildElement("phone", "con"); soapBodyElem7.addTextNode(phone); SOAPElement soapBodyElem8 = soapBodyElem.addChildElement("status", "con"); soapBodyElem8.addTextNode(status); SOAPElement soapBodyElem9 = soapBodyElem.addChildElement("role", "con"); soapBodyElem9.addTextNode(role); SOAPElement soapBodyElem10 = soapBodyElem.addChildElement("access", "con"); soapBodyElem10.addTextNode(access); SOAPElement soapBodyElem11 = soapBodyElem.addChildElement("codetype", "con"); soapBodyElem11.addTextNode(codetype); SOAPElement soapBodyElem12 = soapBodyElem.addChildElement("lang", "con"); soapBodyElem12.addTextNode(language); SOAPElement soapBodyElem13 = soapBodyElem.addChildElement("extrafields", "con"); soapBodyElem13.addTextNode(extrafields); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "/services/ConsoleAdmin"); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.UserDeletion.java
private static SOAPMessage deleteUsers(String loginId, String userId, String serviceId) throws SOAPException, IdentityProvisioningException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); try {/* ww w .j av a 2 s . c o m*/ SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = InweboConnectorConstants.INWEBO_URI; SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("con", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("loginDelete", "con"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("userid", "con"); soapBodyElem1.addTextNode(userId); SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("serviceid", "con"); soapBodyElem2.addTextNode(serviceId); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("loginid", "con"); soapBodyElem3.addTextNode(loginId); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "/services/ConsoleAdmin"); soapMessage.saveChanges(); } catch (SOAPException e) { throw new IdentityProvisioningException("Error while delete the user", e); } return soapMessage; }