Example usage for javax.xml.soap SOAPElement getElementName

List of usage examples for javax.xml.soap SOAPElement getElementName

Introduction

In this page you can find the example usage for javax.xml.soap SOAPElement getElementName.

Prototype

public Name getElementName();

Source Link

Document

Returns the name of this SOAPElement object.

Usage

From source file:it.cnr.icar.eric.server.interfaces.soap.RegistryBSTServlet.java

public SOAPMessage onMessage(SOAPMessage msg, HttpServletRequest req, HttpServletResponse resp) {
    //System.err.println("onMessage called for RegistrySOAPServlet");
    SOAPMessage soapResponse = null;
    SOAPHeader sh = null;/*from  w w  w  .j a va2 s. c  om*/

    try {
        // set 'sh' variable ASAP (before "firstly")
        SOAPPart sp = msg.getSOAPPart();
        SOAPEnvelope se = sp.getEnvelope();
        SOAPBody sb = se.getBody();
        sh = se.getHeader();

        // Firstly we put save the attached repository items in a map
        HashMap<String, Object> idToRepositoryItemMap = new HashMap<String, Object>();
        Iterator<?> apIter = msg.getAttachments();
        while (apIter.hasNext()) {
            AttachmentPart ap = (AttachmentPart) apIter.next();

            //Get the content for the attachment
            RepositoryItem ri = processIncomingAttachment(ap);
            idToRepositoryItemMap.put(ri.getId(), ri);
        }

        // Log received message
        //if (log.isTraceEnabled()) {
        // Warning! BAOS.toString() uses platform's default encoding
        /*
        ByteArrayOutputStream msgOs = new ByteArrayOutputStream();
        msg.writeTo(msgOs);
        msgOs.close();
        System.err.println(msgOs.toString());
        */
        //System.err.println(sb.getTextContent());
        //    log.trace("incoming message:\n" + msgOs.toString());
        //}

        // verify signature
        // returns false if no security header, throws exception if invalid
        CredentialInfo credentialInfo = new CredentialInfo();

        boolean noRegRequired = Boolean.valueOf(
                CommonProperties.getInstance().getProperty("eric.common.noUserRegistrationRequired", "false"))
                .booleanValue();

        if (!noRegRequired) {
            WSS4JSecurityUtilBST.verifySOAPEnvelopeOnServerBST(se, credentialInfo);
        }

        //The ebXML registry request is the only element in the SOAPBody
        StringWriter requestXML = new StringWriter(); //The request as an XML String
        String requestRootElement = null;
        Iterator<?> iter = sb.getChildElements();
        int i = 0;

        while (iter.hasNext()) {
            Object obj = iter.next();

            if (!(obj instanceof SOAPElement)) {
                continue;
            }

            if (i++ == 0) {
                SOAPElement elem = (SOAPElement) obj;
                Name name = elem.getElementName();
                requestRootElement = name.getLocalName();

                StreamResult result = new StreamResult(requestXML);

                TransformerFactory tf = TransformerFactory.newInstance();
                Transformer trans = tf.newTransformer();
                trans.transform(new DOMSource(elem), result);
            } else {
                throw new RegistryException(
                        ServerResourceBundle.getInstance().getString("message.invalidRequest"));
            }
        }

        if (requestRootElement == null) {
            throw new RegistryException(
                    ServerResourceBundle.getInstance().getString("message.noebXMLRegistryRequest"));
        }

        // unmarshalling request to message
        Object message = bu.getRequestObject(requestRootElement, requestXML.toString());

        if (message instanceof JAXBElement<?>) {
            // If Element; take ComplexType from Element
            message = ((JAXBElement<?>) message).getValue();

        }

        // request sets ServerContext with ComplexType: RegistryObjectType
        BSTRequest request = new BSTRequest(req, credentialInfo, message, idToRepositoryItemMap);

        Response response = request.process();

        // response.getMessage() is ComplexType again

        soapResponse = createResponseSOAPMessage(response);

        if (response.getIdToRepositoryItemMap().size() > 0 && (response.getMessage().getStatus()
                .equals(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success))) {

            idToRepositoryItemMap = response.getIdToRepositoryItemMap();
            Iterator<?> mapKeysIter = idToRepositoryItemMap.keySet().iterator();

            while (mapKeysIter.hasNext()) {
                String id = (String) mapKeysIter.next();
                RepositoryItem repositoryItem = (RepositoryItem) idToRepositoryItemMap.get(id);

                String cid = WSS4JSecurityUtilBST.convertUUIDToContentId(id);
                DataHandler dh = repositoryItem.getDataHandler();
                AttachmentPart ap = soapResponse.createAttachmentPart(dh);
                ap.setMimeHeader("Content-Type", "text/xml");
                ap.setContentId(cid);
                soapResponse.addAttachmentPart(ap);

                if (log.isTraceEnabled()) {
                    log.trace("adding attachment: contentId=" + id);
                }
            }

        }

    } catch (Throwable t) {
        //Do not log ObjectNotFoundException as it clutters the log
        if (!(t instanceof ObjectNotFoundException)) {
            log.error(ServerResourceBundle.getInstance().getString("message.CaughtException",
                    new Object[] { t.getMessage() }), t);
            Throwable cause = t.getCause();
            while (cause != null) {
                log.error(ServerResourceBundle.getInstance().getString("message.CausedBy",
                        new Object[] { cause.getMessage() }), cause);
                cause = cause.getCause();
            }
        }

        soapResponse = createFaultSOAPMessage(t, sh);
    }

    if (log.isTraceEnabled()) {
        try {
            ByteArrayOutputStream rspOs = new ByteArrayOutputStream();
            soapResponse.writeTo(rspOs);
            rspOs.close();
            // Warning! BAOS.toString() uses platform's default encoding
            log.trace("response message:\n" + rspOs.toString());
        } catch (Exception e) {
            log.error(ServerResourceBundle.getInstance().getString("message.FailedToLogResponseMessage",
                    new Object[] { e.getMessage() }), e);
        }
    }
    return soapResponse;
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test/*from w w  w . j a  v  a 2 s .  c  om*/
public void testGetElementNameWithoutNamespace() {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    Name name = element.getElementName();
    assertEquals("", name.getURI());
    assertEquals("test", name.getLocalName());
    assertEquals("", name.getPrefix());
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test/*w w  w.  j av  a  2 s .  c  o m*/
public void testGetElementNameWithNamespace() {
    SOAPElement element = saajUtil.createSOAPElement("urn:test", "test", "p");
    Name name = element.getElementName();
    assertEquals("urn:test", name.getURI());
    assertEquals("test", name.getLocalName());
    assertEquals("p", name.getPrefix());
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test//from www . j a va  2 s  .  c  o  m
public void testGetElementNameWithDefaultNamespace() {
    SOAPElement element = saajUtil.createSOAPElement("urn:test", "test", null);
    Name name = element.getElementName();
    assertEquals("urn:test", name.getURI());
    assertEquals("test", name.getLocalName());
    assertEquals("", name.getPrefix());
}

From source file:it.cnr.icar.eric.server.interfaces.soap.RegistrySAMLServlet.java

@SuppressWarnings("unchecked")
public SOAPMessage onMessage(SOAPMessage msg, HttpServletRequest req, HttpServletResponse resp) {

    SOAPMessage soapResponse = null;
    SOAPHeader soapHeader = null;

    try {/*from   ww w  .j  a  v  a 2 s.c o  m*/

        // extract SOAP related parts from incoming SOAP message

        // set 'soapHeader' variable ASAP (before "firstly")
        SOAPPart soapPart = msg.getSOAPPart();
        SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
        SOAPBody soapBody = soapEnvelope.getBody();
        soapHeader = soapEnvelope.getHeader();

        /****************************************************************
         * 
         * REPOSITORY ITEM HANDLING (IN) REPOSITORY ITEM HANDLING (IN)
         * 
         ***************************************************************/

        // Firstly we put save the attached repository items in a map

        HashMap<String, Object> idToRepositoryItemMap = new HashMap<String, Object>();
        Iterator<AttachmentPart> apIter = msg.getAttachments();

        while (apIter.hasNext()) {
            AttachmentPart ap = apIter.next();

            // Get the content for the attachment
            RepositoryItem ri = processIncomingAttachment(ap);
            idToRepositoryItemMap.put(ri.getId(), ri);
        }

        /****************************************************************
         * 
         * LOGGING (IN) LOGGING (IN) LOGGING (IN) LOGGING (IN)
         * 
         ***************************************************************/

        // Log received message

        if (log.isTraceEnabled()) {
            // Warning! BAOS.toString() uses platform's default encoding
            ByteArrayOutputStream msgOs = new ByteArrayOutputStream();
            msg.writeTo(msgOs);
            msgOs.close();
            log.trace("incoming message:\n" + msgOs.toString());
        }

        /****************************************************************
         * 
         * MESSAGE VERIFICATION (IN) MESSAGE VERIFICATION (IN)
         * 
         ***************************************************************/
        CredentialInfo credentialInfo = new CredentialInfo();

        WSS4JSecurityUtilSAML.verifySOAPEnvelopeOnServerSAML(soapEnvelope, credentialInfo);

        /****************************************************************
         * 
         * RS:REQUEST HANDLING RS:REQUEST HANDLING RS:REQUEST
         * 
         ***************************************************************/

        // The ebXML registry request is the only element in the SOAPBody

        StringWriter requestXML = new StringWriter(); // The request as an
        // XML String
        String requestRootElement = null;

        Iterator<?> iter = soapBody.getChildElements();
        int i = 0;

        while (iter.hasNext()) {
            Object obj = iter.next();

            if (!(obj instanceof SOAPElement)) {
                continue;
            }

            if (i++ == 0) {
                SOAPElement elem = (SOAPElement) obj;
                Name name = elem.getElementName();
                requestRootElement = name.getLocalName();

                StreamResult result = new StreamResult(requestXML);
                TransformerFactory tf = TransformerFactory.newInstance();
                Transformer trans = tf.newTransformer();
                trans.transform(new DOMSource(elem), result);
            } else {
                throw new RegistryException(
                        ServerResourceBundle.getInstance().getString("message.invalidRequest"));
            }
        }

        if (requestRootElement == null) {
            throw new RegistryException(
                    ServerResourceBundle.getInstance().getString("message.noebXMLRegistryRequest"));
        }

        // unmarshalling request to message
        Object message = bu.getRequestObject(requestRootElement, requestXML.toString());

        if (message instanceof JAXBElement<?>) {
            // If Element; take ComplexType from Element
            message = ((JAXBElement<?>) message).getValue();
        }

        SAMLRequest request = new SAMLRequest(req, credentialInfo.assertion, message, idToRepositoryItemMap);

        Response response = request.process();

        /****************************************************************
         * 
         * RESPONSE HANDLING RESPONSE HANDLING RESPONSE HANDLING
         * 
         ***************************************************************/

        soapResponse = createResponseSOAPMessage(response);

        if (response.getIdToRepositoryItemMap().size() > 0 && (response.getMessage().getStatus()
                .equals(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success))) {

            idToRepositoryItemMap = response.getIdToRepositoryItemMap();
            Iterator<String> mapKeysIter = idToRepositoryItemMap.keySet().iterator();

            while (mapKeysIter.hasNext()) {
                String id = mapKeysIter.next();
                RepositoryItem repositoryItem = (RepositoryItem) idToRepositoryItemMap.get(id);

                String cid = WSS4JSecurityUtilSAML.convertUUIDToContentId(id);
                DataHandler dh = repositoryItem.getDataHandler();
                AttachmentPart ap = soapResponse.createAttachmentPart(dh);
                ap.setContentId(cid);
                soapResponse.addAttachmentPart(ap);

                if (log.isTraceEnabled()) {
                    log.trace("adding attachment: contentId=" + id);
                }
            }
        }

    } catch (Throwable t) {
        // Do not log ObjectNotFoundException as it clutters the log
        if (!(t instanceof ObjectNotFoundException)) {
            log.error(ServerResourceBundle.getInstance().getString("message.CaughtException",
                    new Object[] { t.getMessage() }), t);
            Throwable cause = t.getCause();
            while (cause != null) {
                log.error(ServerResourceBundle.getInstance().getString("message.CausedBy",
                        new Object[] { cause.getMessage() }), cause);
                cause = cause.getCause();
            }
        }

        soapResponse = createFaultSOAPMessage(t, soapHeader);
    }

    if (log.isTraceEnabled()) {
        try {
            ByteArrayOutputStream rspOs = new ByteArrayOutputStream();
            soapResponse.writeTo(rspOs);
            rspOs.close();
            // Warning! BAOS.toString() uses platform's default encoding
            log.trace("response message:\n" + rspOs.toString());
        } catch (Exception e) {
            log.error(ServerResourceBundle.getInstance().getString("message.FailedToLogResponseMessage",
                    new Object[] { e.getMessage() }), e);
        }
    }
    return soapResponse;
}

From source file:it.cnr.icar.eric.service.validationTest.cppaValidation.CPPAValidation.java

public SOAPElement validateContent(SOAPElement partValidateContentRequest) throws RemoteException {
    try {// w  w w. ja va2  s . co  m
        if (log.isDebugEnabled()) {
            printNodeToConsole(partValidateContentRequest);
        }

        HashMap<String, DataHandler> repositoryItemDHMap = getRepositoryItemDHMap();

        if (log.isDebugEnabled()) {
            log.debug("Attachments: " + repositoryItemDHMap.size());
        }

        Object requestObj = getBindingObjectFromNode(partValidateContentRequest);

        if (!(requestObj instanceof ValidateContentRequest)) {
            throw new Exception(
                    "Wrong response received from validation service.  Expected ValidationContentRequest, got: "
                            + partValidateContentRequest.getElementName().getQualifiedName());
        }

        vcReq = (ValidateContentRequest) requestObj;

        IdentifiableType originalContentIT = vcReq.getOriginalContent().getIdentifiable().get(0).getValue();
        IdentifiableType invocationControlIT = vcReq.getInvocationControlFile().get(0);

        DataHandler originalContentDH = repositoryItemDHMap.get(originalContentIT.getId());
        DataHandler invocationControlDH = repositoryItemDHMap.get(invocationControlIT.getId());

        if (log.isDebugEnabled()) {
            log.debug("originalContentIT id: " + originalContentIT.getId());
            log.debug("invocationControlIT id: " + invocationControlIT.getId());
        }

        StreamSource invocationControlSrc = new StreamSource(invocationControlDH.getInputStream());

        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(invocationControlSrc);

        StringWriter sw = new StringWriter();
        transformer.transform(new StreamSource(originalContentDH.getInputStream()), new StreamResult(sw));

        vcResp = cmsFac.createValidateContentResponse();

        boolean success = Boolean.valueOf(sw.toString()).booleanValue();

        if (success) {
            vcResp.setStatus(CANONICAL_RESPONSE_STATUS_TYPE_ID_Success);
        } else {
            RegistryError re = rsFac.createRegistryError();
            re.setValue(sw.toString());
            re.setCodeContext(errorCodeContext);
            re.setErrorCode("InvalidContentException");

            RegistryErrorList el = rsFac.createRegistryErrorList();
            el.getRegistryError().add(re);
            el.setHighestSeverity("Failure");

            vcResp.setStatus(CANONICAL_RESPONSE_STATUS_TYPE_ID_Failure);
            vcResp.setRegistryErrorList(el);
        }

        vcRespElement = getSOAPElementFromBindingObject(vcResp);
    } catch (Exception e) {
        throw new RemoteException("Could not create response.", e);
    }

    return vcRespElement;
}

From source file:it.cnr.icar.eric.service.catalogingTest.cppaCataloging.CPPACataloging.java

public SOAPElement catalogContent(SOAPElement partCatalogContentRequest) throws RemoteException {
    try {//from   ww  w  .  j  av  a2s .com
        if (log.isDebugEnabled()) {
            printNodeToConsole(partCatalogContentRequest);
        }

        final HashMap<String, DataHandler> repositoryItemDHMap = getRepositoryItemDHMap();

        if (log.isDebugEnabled()) {
            log.debug("Attachments: " + repositoryItemDHMap.size());
        }

        Object requestObj = getBindingObjectFromNode(partCatalogContentRequest);

        if (!(requestObj instanceof CatalogContentRequest)) {
            throw new Exception(
                    "Wrong response received from validation service.  Expected CatalogContentRequest, got: "
                            + partCatalogContentRequest.getElementName().getQualifiedName());
        }

        ccReq = (CatalogContentRequest) requestObj;

        IdentifiableType originalContentIT = ccReq.getOriginalContent().getIdentifiable().get(0).getValue();
        IdentifiableType invocationControlIT = ccReq.getInvocationControlFile().get(0);

        DataHandler invocationControlDH = repositoryItemDHMap.get(invocationControlIT.getId());

        if (log.isDebugEnabled()) {
            log.debug("originalContentIT id: " + originalContentIT.getId());
            log.debug("invocationControlIT id: " + invocationControlIT.getId());
        }

        StreamSource invocationControlSrc = new StreamSource(invocationControlDH.getInputStream());

        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(invocationControlSrc);

        transformer.setURIResolver(new URIResolver() {
            public Source resolve(String href, String base) throws TransformerException {
                Source source = null;
                try {
                    // Should this check that href is UUID URN first?
                    source = new StreamSource((repositoryItemDHMap.get(href)).getInputStream());
                } catch (Exception e) {
                    source = null;
                }

                return source;
            }
        });
        transformer.setErrorListener(new ErrorListener() {
            public void error(TransformerException exception) throws TransformerException {
                log.info(exception);
            }

            public void fatalError(TransformerException exception) throws TransformerException {
                log.error(exception);
                throw exception;
            }

            public void warning(TransformerException exception) throws TransformerException {
                log.info(exception);
            }
        });

        //Set respository item as parameter
        transformer.setParameter("repositoryItem", originalContentIT.getId());

        StringWriter sw = new StringWriter();
        transformer.transform(new JAXBSource(jaxbContext, originalContentIT), new StreamResult(sw));

        ccResp = cmsFac.createCatalogContentResponse();

        RegistryObjectListType catalogedMetadata = (RegistryObjectListType) getUnmarshaller()
                .unmarshal(new StreamSource(new StringReader(sw.toString())));
        RegistryObjectListType roList = rimFac.createRegistryObjectListType();
        ccResp.setCatalogedContent(roList);
        // FIXME: Setting catalogedMetadata as CatalogedContent results in incorrect serialization.
        roList.getIdentifiable().addAll(catalogedMetadata.getIdentifiable());

        ccResp.setStatus(CANONICAL_RESPONSE_STATUS_TYPE_ID_Success);

        ccRespElement = getSOAPElementFromBindingObject(ccResp);

        // Copy request's attachments to response to exercise attachment-processing code on client.
        MessageContext mc = servletEndpointContext.getMessageContext();
        mc.setProperty(com.sun.xml.rpc.server.ServerPropertyConstants.SET_ATTACHMENT_PROPERTY,
                (Collection<?>) mc
                        .getProperty(com.sun.xml.rpc.server.ServerPropertyConstants.GET_ATTACHMENT_PROPERTY));

    } catch (Exception e) {
        throw new RemoteException("Could not create response.", e);
    }

    return ccRespElement;
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test/*  w w  w . java 2  s  .c  o  m*/
public void testGetChildElementsByName() throws Exception {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    SOAPElement a1 = element.addChildElement(new QName("urn:ns1", "a"));
    element.addChildElement(new QName("urn:ns2", "a"));
    SOAPElement a2 = element.addChildElement(new QName("urn:ns1", "a", "ns1"));
    element.addChildElement(new QName("urn:ns1", "b"));
    Iterator it = element.getChildElements(a1.getElementName());
    assertTrue(it.hasNext());
    assertSame(a1, it.next());
    assertTrue(it.hasNext());
    assertSame(a2, it.next());
    assertFalse(it.hasNext());
}

From source file:com.twinsoft.convertigo.engine.translators.WebServiceTranslator.java

public void buildInputDocument(Context context, Object inputData) throws Exception {
    Engine.logBeans.debug("[WebServiceTranslator] Making input document");

    HttpServletRequest request = (HttpServletRequest) inputData;

    SOAPMessage requestMessage = (SOAPMessage) request
            .getAttribute(WebServiceServlet.REQUEST_MESSAGE_ATTRIBUTE);

    SOAPPart sp = requestMessage.getSOAPPart();
    SOAPEnvelope se = sp.getEnvelope();
    SOAPBody sb = se.getBody();//from w  ww.j  av  a 2  s  . c om

    Iterator<?> iterator = sb.getChildElements();
    SOAPElement method, parameter;
    String methodName;

    InputDocumentBuilder inputDocumentBuilder = new InputDocumentBuilder(context);

    while (iterator.hasNext()) {
        List<RequestableVariable> variableList = null; // jmc 12/06/26

        Object element = iterator.next();
        if (element instanceof SOAPElement) {
            method = (SOAPElement) element;

            methodName = method.getElementName().getLocalName();
            Engine.logBeans.debug("[WebServiceTranslator] Requested web service name: " + methodName);

            int i = methodName.indexOf("__");

            // for statefull transaction, don't replace the project
            if (context.project == null || !context.project.getName().equals(context.projectName)) {
                context.project = Engine.theApp.databaseObjectsManager.getProjectByName(context.projectName);
            }

            String connectorName = null;
            if (i == -1) {
                context.connectorName = null;
                context.sequenceName = methodName;
            } else {
                connectorName = methodName.substring(0, i);
                context.transactionName = methodName.substring(i + 2);
            }

            if ((connectorName != null) && (!connectorName.equals(context.connectorName))) {
                Engine.logBeans.debug("Connector name differs from previous one; requiring new session");
                context.isNewSession = true;
                context.connectorName = connectorName;
                Engine.logBeans.debug("[WebServiceTranslator] The connector is overridden to \""
                        + context.connectorName + "\".");
            }

            Engine.logBeans.debug("[WebServiceTranslator] Connector: "
                    + (context.connectorName == null ? "(default)" : context.connectorName));
            Engine.logBeans.debug("[WebServiceTranslator] Transaction: " + context.transactionName);

            //Connector connector = (context.connectorName == null ? context.project.getDefaultConnector() : context.project.getConnectorByName(context.connectorName));
            //Transaction transaction = (context.transactionName == null ? connector.getDefaultTransaction() : connector.getTransactionByName(context.transactionName));
            RequestableObject requestable = null;
            if (context.sequenceName != null) {
                requestable = context.project.getSequenceByName(context.sequenceName);
                variableList = ((Sequence) requestable).getVariablesList();
            } else if (context.connectorName != null) {
                if (context.transactionName != null) {
                    requestable = context.project.getConnectorByName(context.connectorName)
                            .getTransactionByName(context.transactionName);
                    if (requestable instanceof TransactionWithVariables) {
                        variableList = ((TransactionWithVariables) requestable).getVariablesList();
                    }
                }
            }

            Iterator<?> iterator2 = method.getChildElements();
            String parameterName, parameterValue;

            while (iterator2.hasNext()) {
                element = iterator2.next();
                if (element instanceof SOAPElement) {
                    parameter = (SOAPElement) element;
                    parameterName = parameter.getElementName().getLocalName();
                    parameterValue = parameter.getValue();
                    if (parameterValue == null) {
                        parameterValue = "";
                    }

                    if (variableList != null) { // jmc 12/06/26 hide hidden variables in sequences
                        String str = (String) Visibility.Logs.replaceVariables(variableList,
                                "" + parameterName + "=\"" + parameterValue + "\"");
                        Engine.logBeans.debug("   Parameter: " + str);
                    } else
                        Engine.logBeans.debug("   Parameter: " + parameterName + "=\"" + parameterValue + "\"");

                    // Handle convertigo parameters
                    if (parameterName.startsWith("__")) {
                        webServiceServletRequester.handleParameter(parameterName, parameterValue);
                    }

                    // Common parameter handling
                    if (inputDocumentBuilder.handleSpecialParameter(parameterName, parameterValue)) {
                        // handled
                    }
                    // Compatibility for Convertigo 2.x
                    else if (parameterName.equals("context")) {
                        // Just ignore it
                    } else {
                        SOAPElement soapArrayElement = null;
                        Iterator<?> iterator3;

                        String href = parameter.getAttributeValue(se.createName("href"));

                        String arrayType = parameter.getAttributeValue(se.createName("soapenc:arrayType"));
                        if (arrayType == null) {
                            iterator3 = parameter.getAllAttributes();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof Name) {
                                    String s = ((Name) element).getQualifiedName();
                                    if (s.equals("soapenc:arrayType")) {
                                        arrayType = s;
                                        break;
                                    }
                                }
                            }
                        }

                        // Array (Microsoft .net)
                        if (href != null) {
                            Engine.logBeans.debug("Deserializing Microsoft .net array");
                            iterator3 = sb.getChildElements();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof SOAPElement) {
                                    soapArrayElement = (SOAPElement) element;
                                    String elementId = soapArrayElement.getAttributeValue(se.createName("id"));
                                    if (elementId != null) {
                                        if (href.equals("#" + elementId)) {
                                            iterator3 = soapArrayElement.getChildElements();
                                            while (iterator3.hasNext()) {
                                                element = iterator3.next();
                                                if (element instanceof SOAPElement) {
                                                    break;
                                                }
                                            }
                                            break;
                                        }
                                    }
                                }
                            }

                            // Find the element with href id
                            iterator3 = sb.getChildElements();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof SOAPElement) {
                                    soapArrayElement = (SOAPElement) element;
                                    String elementId = soapArrayElement.getAttributeValue(se.createName("id"));
                                    if (elementId != null) {
                                        if (href.equals("#" + elementId)) {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        // Array (Java/Axis)
                        else if (arrayType != null) {
                            Engine.logBeans.debug("Deserializing Java/Axis array");
                            soapArrayElement = parameter;
                        }
                        // If the node has children nodes, we assume it is an array.
                        else if (parameter.getChildElements().hasNext()) {
                            if (isSoapArray((IVariableContainer) requestable, parameterName)) {
                                Engine.logBeans.debug("Deserializing array");
                                soapArrayElement = parameter;
                            }
                        }

                        // Deserializing array
                        if (soapArrayElement != null) {
                            iterator3 = soapArrayElement.getChildElements();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof SOAPElement) {
                                    soapArrayElement = (SOAPElement) element;
                                    parameterValue = soapArrayElement.getValue();
                                    if (parameterValue == null)
                                        parameterValue = "";
                                    handleSimpleVariable(context.inputDocument, soapArrayElement, parameterName,
                                            parameterValue, inputDocumentBuilder.transactionVariablesElement);
                                }
                            }
                        }
                        // Deserializing simple variable
                        else {
                            handleSimpleVariable(context.inputDocument, parameter, parameterName,
                                    parameterValue, inputDocumentBuilder.transactionVariablesElement);
                        }
                    }
                }
            }

            if (Engine.logBeans.isDebugEnabled()) {
                String soapMessage = SOAPUtils.toString(requestMessage, request.getCharacterEncoding());

                if (requestable instanceof TransactionWithVariables)
                    Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n"
                            + Visibility.Logs.replaceVariables(
                                    ((TransactionWithVariables) (requestable)).getVariablesList(), request));
                else if (requestable instanceof Sequence)
                    Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + Visibility.Logs
                            .replaceVariables(((Sequence) (requestable)).getVariablesList(), request));
                else
                    Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + soapMessage);
            }

            break;
        }
    }

    Engine.logBeans.debug("[WebServiceTranslator] SOAP message analyzed");

    Engine.logBeans.debug("[WebServiceTranslator] Input document created");
}

From source file:it.cnr.icar.eric.server.cms.ContentValidationServiceImpl.java

public ServiceOutput invoke(ServerRequestContext context, ServiceInput input, ServiceType service,
        InvocationController invocationController, UserType user) throws RegistryException {
    System.err.println("ContentValidationServiceImpl.invoke():: input: " + input + "; Service: " + service
            + "; invocationController: " + invocationController + "; user: " + user);

    List<ServiceBindingType> serviceBindings = service.getServiceBinding();
    Iterator<ServiceBindingType> debugIter = serviceBindings.iterator();

    while (debugIter.hasNext()) {
        ServiceBindingType binding = debugIter.next();
        System.err.println("URL: " + binding.getAccessURI());
    }//from ww w. j  av a 2  s.c  om

    String accessURI = selectAccessURI(service);

    SOAPElement responseElement;
    Object responseObj;

    try {
        ValidateContentRequest ebValidateContentRequest = bu.cmsFac.createValidateContentRequest();
        RegistryObjectListType ebRegistryObjectListType = bu.rimFac.createRegistryObjectListType();

        JAXBElement<RegistryObjectType> ebRegistryObject = bu.rimFac
                .createRegistryObject(input.getRegistryObject());
        ebRegistryObjectListType.getIdentifiable().add(ebRegistryObject);
        ebValidateContentRequest.setOriginalContent(ebRegistryObjectListType);

        System.err.println("InvocationControlFile class: "
                + qm.getRegistryObject(context, invocationController.getEoId()).getClass().getName());

        // FIXME: Adding existing ExtrinsicObjects with 'request.getInvocationControlFile().add()' gives incorrect serialization.
        ExtrinsicObjectType icfEOT = bu.rimFac.createExtrinsicObjectType();
        icfEOT.setId(invocationController.getEoId());
        ebValidateContentRequest.getInvocationControlFile().add(icfEOT);

        System.out.println("\n\nOriginalContent:");
        printNodeToConsole(bu.getSOAPElementFromBindingObject(input.getRegistryObject()));

        ArrayList<AttachmentPart> attachments = new ArrayList<AttachmentPart>();

        // RepositoryItem for input to be validated.
        attachments.add(getRepositoryItemAsAttachmentPart(input.getRegistryObject().getId()));

        // RepositoryItem for InvocationControlFile.
        attachments.add(getRepositoryItemAsAttachmentPart(invocationController.getEoId()));

        ContentValidationServiceSOAPService soapService = new ContentValidationServiceSOAPService_Impl();
        ContentValidationServicePortType_Stub stub = (ContentValidationServicePortType_Stub) soapService
                .getContentValidationServicePort();
        stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, accessURI);
        stub._setProperty(com.sun.xml.rpc.client.StubPropertyConstants.SET_ATTACHMENT_PROPERTY, attachments);

        responseElement = stub.validateContent(bu.getSOAPElementFromBindingObject(ebValidateContentRequest));

        responseObj = bu.getBindingObjectFromSOAPElement(responseElement);
    } catch (Exception e) {
        throw new RegistryException(e);
    }

    if (!(responseObj instanceof ValidateContentResponse)) {
        throw new RegistryException(
                ServerResourceBundle.getInstance().getString("message.ValidationContentResponseExpected",
                        new Object[] { responseElement.getElementName().getQualifiedName() }));
    }

    ValidateContentResponse ebValidateContentResponse = (ValidateContentResponse) responseObj;

    String status = ebValidateContentResponse.getStatus();

    System.err.println("Status: " + status);

    if (log.isDebugEnabled()) {
        log.debug("Status: " + status);
    }

    ServiceOutput output = new ServiceOutput();
    output.setErrorList(ebValidateContentResponse.getRegistryErrorList());

    if (status.equals(CanonicalSchemes.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success)) {
        output.setOutput(Boolean.TRUE);
    } else if (status.equals(CanonicalSchemes.CANONICAL_RESPONSE_STATUS_TYPE_ID_Failure)) {
        output.setOutput(Boolean.FALSE);
    } else {
        throw new RegistryException(ServerResourceBundle.getInstance()
                .getString("message.ResponseStatusTypeExpected", new Object[] { status }));
    }

    return output;
}