Example usage for javax.xml.soap SOAPBody addChildElement

List of usage examples for javax.xml.soap SOAPBody addChildElement

Introduction

In this page you can find the example usage for javax.xml.soap SOAPBody addChildElement.

Prototype

public SOAPElement addChildElement(String localName, String prefix) throws SOAPException;

Source Link

Document

Creates a new SOAPElement object initialized with the specified local name and prefix and adds the new element to this SOAPElement object.

Usage

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   ww  w  . jav a  2s  .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 .j  a va  2s. 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;
}