Example usage for javax.xml.soap MessageFactory newInstance

List of usage examples for javax.xml.soap MessageFactory newInstance

Introduction

In this page you can find the example usage for javax.xml.soap MessageFactory newInstance.

Prototype

public static MessageFactory newInstance() throws SOAPException 

Source Link

Document

Creates a new MessageFactory object that is an instance of the default implementation (SOAP 1.1).

Usage

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  av  a 2s .c  om
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.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  a2 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);//from  w w w .j  av  a2  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);/*ww w.  j  av  a  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  .c o 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 {//from   w  w w.java  2  s  .  c  om
        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 ww  w. j  av 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:org.wso2.carbon.identity.sso.saml.servlet.SAMLArtifactResolveServlet.java

/**
 * All requests are handled by this handleRequest method. Request should come with a soap envelop that
 * wraps an ArtifactResolve object. First we try to extract resolve object and if successful, call
 * handle artifact method./*  ww  w  .  j ava2 s.  com*/
 *
 * @param req  HttpServletRequest object received.
 * @param resp HttpServletResponse object to be sent.
 * @throws ServletException
 * @throws IOException
 */
private void handleRequest(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    try {
        ArtifactResolve artifactResolve = null;
        try {
            MessageFactory messageFactory = MessageFactory.newInstance();
            InputStream inStream = req.getInputStream();
            SOAPMessage soapMessage = messageFactory.createMessage(new MimeHeaders(), inStream);
            if (log.isDebugEnabled()) {
                OutputStream outputStream = new ByteArrayOutputStream();
                soapMessage.writeTo(outputStream);
                log.debug("SAML2 Artifact Resolve request received: " + outputStream.toString());
            }
            SOAPBody soapBody = soapMessage.getSOAPBody();
            Iterator iterator = soapBody.getChildElements();

            while (iterator.hasNext()) {
                SOAPBodyElement artifactResolveElement = (SOAPBodyElement) iterator.next();

                if (StringUtils.equals(SAMLConstants.SAML20P_NS, artifactResolveElement.getNamespaceURI())
                        && StringUtils.equals(ArtifactResolve.DEFAULT_ELEMENT_LOCAL_NAME,
                                artifactResolveElement.getLocalName())) {

                    DOMSource source = new DOMSource(artifactResolveElement);
                    StringWriter stringResult = new StringWriter();
                    TransformerFactory.newInstance().newTransformer().transform(source,
                            new StreamResult(stringResult));
                    artifactResolve = (ArtifactResolve) SAMLSSOUtil.unmarshall(stringResult.toString());
                }
            }
        } catch (SOAPException e) {
            throw new ServletException("Error while extracting SOAP body from the request.", e);
        } catch (TransformerException e) {
            throw new ServletException("Error while extracting ArtifactResponse from the request.", e);
        } catch (IdentityException e) {
            throw new ServletException("Error while unmarshalling ArtifactResponse  from the request.", e);
        }

        if (artifactResolve != null) {
            handleArtifact(req, resp, artifactResolve);
        } else {
            log.error("Invalid SAML Artifact Resolve request received.");
        }

    } finally {
        SAMLSSOUtil.removeSaaSApplicationThreaLocal();
        SAMLSSOUtil.removeUserTenantDomainThreaLocal();
        SAMLSSOUtil.removeTenantDomainFromThreadLocal();
    }
}

From source file:org.wso2.carbon.identity.sso.saml.servlet.SAMLECPProviderServlet.java

/**
 * This method returns s SOAP message from the given Servlet Input Stream.
 * @param inputStream InputStream from the servlet Request
 * @return/*from  w  w w .  java  2 s.c  o  m*/
 * @throws IOException
 * @throws SOAPException
 */
private SOAPMessage createSOAPMessagefromInputStream(InputStream inputStream)
        throws SOAPException, IOException {
    SOAPMessage soapMessage;
    MessageFactory messageFactory = MessageFactory.newInstance();
    soapMessage = messageFactory.createMessage(new MimeHeaders(), inputStream);
    return soapMessage;
}

From source file:org.wso2.carbon.identity.sso.saml.TestUtils.java

public static SOAPMessage getSOAPBindedSAMLAuthnRequest() {
    SOAPMessage soapMessage = null;
    String stringMsg = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><samlp:AuthnRequest "
            + "xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" AssertionConsumerServiceURL=\"https://localhost/Shib"
            + "boleth.sso/SAML2/ECP\" ID=\"_ec1025e786e6fff206ef63909029202a\" IssueInstant=\"2018-10-22T11:41:10Z\" Pro"
            + "tocolBinding=\"urn:oasis:names:tc:SAML:2.0:bindings:PAOS\" Version=\"2.0\"><saml:Issuer xmlns:saml=\"urn:"
            + "oasis:names:tc:SAML:2.0:assertion\">https://localhost/shibboleth</saml:Issuer><samlp:NameIDPolicy AllowCr"
            + "eate=\"1\"/><samlp:Scoping><samlp:IDPList><samlp:IDPEntry ProviderID=\"https://idp.is.com\"/></samlp:IDPL"
            + "ist></samlp:Scoping></samlp:AuthnRequest></S:Body></S:Envelope>";
    try {// w  w w.  j  a v a 2  s  . com
        InputStream is = new ByteArrayInputStream(stringMsg.getBytes(Charset.forName("UTF-8")));
        soapMessage = MessageFactory.newInstance().createMessage(null, is);
    } catch (Exception e) {
        log.error("Error Creating the SOAP message");
    }
    return soapMessage;

}