List of usage examples for javax.xml.soap SOAPElement addChildElement
public SOAPElement addChildElement(String localName, String prefix) throws SOAPException;
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 ww w . ja v a 2 s.co m 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);//from w w w .ja v a 2 s . co m 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);//www . j a v a 2s .co 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);/*from ww w .j a va2s.com*/ 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 {/*from w w w. j a v 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; }
From source file:org.wso2.carbon.identity.provisioning.connector.UserUpdation.java
private static SOAPMessage createUserObject(String userId, String serviceId, String loginId, String login, String firstName, String name, String mail, String phone, String status, String role, 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("loginUpdate", "con"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("userid", "con"); soapBodyElem1.addTextNode(userId);/*from w w w . ja v a 2 s. c o m*/ SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("serviceid", "con"); soapBodyElem2.addTextNode(serviceId); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("loginid", "con"); soapBodyElem3.addTextNode(loginId); SOAPElement soapBodyElem4 = soapBodyElem.addChildElement("login", "con"); soapBodyElem4.addTextNode(login); SOAPElement soapBodyElem5 = soapBodyElem.addChildElement("firstname", "con"); soapBodyElem5.addTextNode(firstName); SOAPElement soapBodyElem6 = soapBodyElem.addChildElement("name", "con"); soapBodyElem6.addTextNode(name); SOAPElement soapBodyElem7 = soapBodyElem.addChildElement("mail", "con"); soapBodyElem7.addTextNode(mail); SOAPElement soapBodyElem8 = soapBodyElem.addChildElement("phone", "con"); soapBodyElem8.addTextNode(phone); SOAPElement soapBodyElem9 = soapBodyElem.addChildElement("status", "con"); soapBodyElem9.addTextNode(status); SOAPElement soapBodyElem10 = soapBodyElem.addChildElement("role", "con"); soapBodyElem10.addTextNode(role); SOAPElement soapBodyElem11 = soapBodyElem.addChildElement("extrafields", "con"); soapBodyElem11.addTextNode(extraFields); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "/services/ConsoleAdmin"); soapMessage.saveChanges(); return soapMessage; }
From source file:ru.codeinside.gws.crypto.cryptopro.CryptoProvider.java
public void sign(final SOAPMessage message) { try {/* ww w . ja va 2s.co m*/ loadCertificate(); final long startMs = System.currentTimeMillis(); final SOAPPart doc = message.getSOAPPart(); final QName wsuId = doc.getEnvelope().createQName("Id", "wsu"); final SOAPHeader header = message.getSOAPHeader(); final QName actor = header.createQName("actor", header.getPrefix()); final SOAPElement security = header.addChildElement("Security", "wsse", WSSE); security.addAttribute(actor, ACTOR_SMEV); SOAPElement binarySecurityToken = security.addChildElement("BinarySecurityToken", "wsse"); binarySecurityToken.setAttribute("EncodingType", WSS_BASE64_BINARY); binarySecurityToken.setAttribute("ValueType", WSS_X509V3); binarySecurityToken.setValue(DatatypeConverter.printBase64Binary(cert.getEncoded())); binarySecurityToken.addAttribute(wsuId, "CertId"); XMLSignature signature = new XMLSignature(doc, "", XMLSignature.ALGO_ID_SIGNATURE_GOST_GOST3410_3411, Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); { Element element = signature.getElement(); Element keyInfo = doc.createElementNS(Constants.SignatureSpecNS, "KeyInfo"); Element securityTokenReference = doc.createElementNS(WSSE, "SecurityTokenReference"); Element reference = doc.createElementNS(WSSE, "Reference"); reference.setAttribute("URI", "#CertId"); reference.setAttribute("ValueType", WSS_X509V3); securityTokenReference.appendChild(reference); keyInfo.appendChild(securityTokenReference); element.appendChild(keyInfo); security.appendChild(element); } Transforms transforms = new Transforms(doc); transforms.addTransform(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); signature.addDocument("#body", transforms, MessageDigestAlgorithm.ALGO_ID_DIGEST_GOST3411); signature.sign(privateKey); if (log.isDebugEnabled()) { log.debug("SIGN: " + (System.currentTimeMillis() - startMs) + "ms"); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:test.saaj.TestAttachmentSerialization.java
public int saveMsgWithAttachments(OutputStream os) throws Exception { MessageFactory mf = MessageFactory.newInstance(); SOAPMessage msg = mf.createMessage(); SOAPPart sp = msg.getSOAPPart(); SOAPEnvelope envelope = sp.getEnvelope(); SOAPHeader header = envelope.getHeader(); SOAPBody body = envelope.getBody(); SOAPElement el = header.addHeaderElement(envelope.createName("field4", NS_PREFIX, NS_URI)); SOAPElement el2 = el.addChildElement("field4b", NS_PREFIX); SOAPElement el3 = el2.addTextNode("field4value"); el = body.addBodyElement(envelope.createName("bodyfield3", NS_PREFIX, NS_URI)); el2 = el.addChildElement("bodyfield3a", NS_PREFIX); el2.addTextNode("bodyvalue3a"); el2 = el.addChildElement("bodyfield3b", NS_PREFIX); el2.addTextNode("bodyvalue3b"); el2 = el.addChildElement("datefield", NS_PREFIX); AttachmentPart ap = msg.createAttachmentPart(); ap.setContent("some attachment text...", "text/plain"); msg.addAttachmentPart(ap);//from www. j av a 2 s .com String jpgfilename = "docs/images/axis.jpg"; File myfile = new File(jpgfilename); FileDataSource fds = new FileDataSource(myfile); DataHandler dh = new DataHandler(fds); AttachmentPart ap2 = msg.createAttachmentPart(dh); ap2.setContentType("image/jpg"); msg.addAttachmentPart(ap2); // Test for Bug #17664 if (msg.saveRequired()) { msg.saveChanges(); } MimeHeaders headers = msg.getMimeHeaders(); assertTrue(headers != null); String[] contentType = headers.getHeader("Content-Type"); assertTrue(contentType != null); msg.writeTo(os); os.flush(); return msg.countAttachments(); }