Example usage for javax.xml.namespace QName getLocalPart

List of usage examples for javax.xml.namespace QName getLocalPart

Introduction

In this page you can find the example usage for javax.xml.namespace QName getLocalPart.

Prototype

public String getLocalPart() 

Source Link

Document

Get the local part of this QName.

Usage

From source file:org.apache.axis2.schema.writer.JavaBeanWriter.java

private boolean typeChanged(QName qname, ArrayList<QName> missingQNames, BeanWriterMetaInfoHolder metainf) {

    boolean typeChanged = false;
    QName[] pQNames;/*from  w  w w. jav a  2  s  .  c o m*/

    BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();

    if (parentMetainf != null && !missingQNames.contains(qname)) {

        if (parentMetainf.isOrdered()) {
            pQNames = parentMetainf.getOrderedQNameArray();
        } else {
            pQNames = parentMetainf.getQNameArray();
        }

        for (int j = 0; j < pQNames.length; j++) {
            if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {

                String javaClassForParentElement = parentMetainf.getClassNameForQName(pQNames[j]);
                String javaClassForElement = metainf.getClassNameForQName(qname);

                if (!javaClassForParentElement.equals(javaClassForElement)) {
                    if (javaClassForParentElement.endsWith("[]")) {
                        if ((javaClassForParentElement.substring(0, javaClassForParentElement.indexOf('[')))
                                .equals(javaClassForElement)) {
                            continue;
                        }
                    } else if (javaClassForElement.endsWith("[]")) {
                        if ((javaClassForElement.substring(0, javaClassForElement.indexOf('[')))
                                .equals(javaClassForParentElement)) {
                            continue;
                        }
                    } else {
                        typeChanged = true;
                    }
                }
            }
        }
    }
    return typeChanged;
}

From source file:org.apache.axis2.schema.writer.JavaBeanWriter.java

private boolean minOccursChanged(QName qname, ArrayList<QName> missingQNames, BeanWriterMetaInfoHolder metainf)
        throws SchemaCompilationException {

    boolean minChanged = false;
    QName[] pQNames;//ww w.ja v a  2  s . c o  m

    BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();

    if (parentMetainf != null && !missingQNames.contains(qname)) {

        if (parentMetainf.isOrdered()) {
            pQNames = parentMetainf.getOrderedQNameArray();
        } else {
            pQNames = parentMetainf.getQNameArray();
        }

        for (int j = 0; j < pQNames.length; j++) {
            if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {

                if (metainf.getMinOccurs(qname) > parentMetainf.getMinOccurs(pQNames[j])) {
                    minChanged = true;
                } else if (metainf.getMinOccurs(qname) < parentMetainf.getMinOccurs(pQNames[j])) {
                    throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("minOccurs Wrong!"));
                }

            }
        }
    }
    return minChanged;
}

From source file:org.apache.axis2.schema.writer.JavaBeanWriter.java

private boolean maxOccursChanged(QName qname, ArrayList<QName> missingQNames, BeanWriterMetaInfoHolder metainf)
        throws SchemaCompilationException {

    boolean maxChanged = false;
    QName[] pQNames;/*from  w  w  w  . ja  v  a  2s .c  o  m*/

    BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();

    if (parentMetainf != null && !missingQNames.contains(qname)) {
        if (parentMetainf.isOrdered()) {
            pQNames = parentMetainf.getOrderedQNameArray();
        } else {
            pQNames = parentMetainf.getQNameArray();
        }

        for (int j = 0; j < pQNames.length; j++) {
            if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {

                if (metainf.getMaxOccurs(qname) < parentMetainf.getMaxOccurs(pQNames[j])) {
                    maxChanged = true;
                } else if (metainf.getMaxOccurs(qname) > parentMetainf.getMaxOccurs(pQNames[j])) {
                    throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("maxOccurs Wrong!"));
                }
            }
        }
    }
    return maxChanged;
}

From source file:org.apache.axis2.schema.writer.JavaBeanWriter.java

/**
 * Write the extension classes - this is needed to process
 * the hierarchy of classes/*from w w  w  . j  ava  2s . c  o  m*/
 *
 * @param metainfArray
 */
public void writeExtensionMapper(BeanWriterMetaInfoHolder[] metainfArray) throws SchemaCompilationException {
    //generate the element
    try {

        String mapperClassName = getFullyQualifiedMapperClassName();

        Document model = XSLTUtils.getDocument();
        Element rootElt = XSLTUtils.getElement(model, "mapper");
        String mapperName = mapperClassName.substring(mapperClassName.lastIndexOf(".") + 1);
        XSLTUtils.addAttribute(model, "name", mapperName, rootElt);
        String basePackageName = "";
        if (mapperClassName.indexOf(".") != -1) {
            basePackageName = mapperClassName.substring(0, mapperClassName.lastIndexOf("."));
            XSLTUtils.addAttribute(model, "package", basePackageName, rootElt);
        } else {
            XSLTUtils.addAttribute(model, "package", "", rootElt);
        }

        if (!wrapClasses) {
            XSLTUtils.addAttribute(model, "unwrapped", "yes", rootElt);
        }

        if (!writeClasses) {
            XSLTUtils.addAttribute(model, "skip-write", "yes", rootElt);
        }

        if (isHelperMode) {
            XSLTUtils.addAttribute(model, "helpermode", "yes", rootElt);
        }

        for (int i = 0; i < metainfArray.length; i++) {
            QName ownQname = metainfArray[i].getOwnQname();
            String className = metainfArray[i].getOwnClassName();
            //do  not add when the qname is not availble
            if (ownQname != null) {
                Element typeChild = XSLTUtils.addChildElement(model, "type", rootElt);
                XSLTUtils.addAttribute(model, "nsuri", ownQname.getNamespaceURI(), typeChild);
                XSLTUtils.addAttribute(model, "classname", className == null ? "" : className, typeChild);
                XSLTUtils.addAttribute(model, "shortname", ownQname == null ? "" : ownQname.getLocalPart(),
                        typeChild);
            }
        }

        model.appendChild(rootElt);

        if (!templateLoaded) {
            loadTemplate();
        }

        if (wrapClasses) {
            rootElt = (Element) globalWrappedDocument.importNode(rootElt, true);
            //add to the global wrapped document
            globalWrappedDocument.getDocumentElement().appendChild(rootElt);
        } else {
            if (writeClasses) {
                // create the file
                File out = createOutFile(basePackageName, mapperName);
                // parse with the template and create the files
                parse(model, out);

            }

            // add the model to the model map
            modelMap.put(new QName(mapperName), model);
        }

    } catch (ParserConfigurationException e) {
        throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.docuement.error"), e);
    } catch (Exception e) {
        e.printStackTrace();
        throw new SchemaCompilationException(e);
    }

}

From source file:org.apache.axis2.transport.sms.DefaultSMSMessageBuilderImpl.java

private SOAPEnvelope createSoapEnvelope(MessageContext messageContext, Map params) {
    SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
    SOAPEnvelope inEnvlope = soapFactory.getDefaultEnvelope();
    SOAPBody inBody = inEnvlope.getBody();
    XmlSchemaElement xmlSchemaElement;//from   w  ww.  j ava2  s.  c om
    AxisOperation axisOperation = messageContext.getAxisOperation();
    if (axisOperation != null) {
        AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        xmlSchemaElement = axisMessage.getSchemaElement();

        if (xmlSchemaElement == null) {
            OMElement bodyFirstChild = soapFactory.createOMElement(messageContext.getAxisOperation().getName(),
                    inBody);
            createSOAPMessageWithoutSchema(soapFactory, bodyFirstChild, params);
        } else {

            // first get the target namespace from the schema and the wrapping element.
            // create an OMElement out of those information. We are going to extract parameters from
            // url, create OMElements and add them as children to this wrapping element.
            String targetNamespace = xmlSchemaElement.getQName().getNamespaceURI();
            QName bodyFirstChildQName;
            if (targetNamespace != null && !"".equals(targetNamespace)) {
                bodyFirstChildQName = new QName(targetNamespace, xmlSchemaElement.getName());
            } else {
                bodyFirstChildQName = new QName(xmlSchemaElement.getName());
            }
            OMElement bodyFirstChild = soapFactory.createOMElement(bodyFirstChildQName, inBody);

            // Schema should adhere to the IRI style in this. So assume IRI style and dive in to
            // schema
            XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
            if (schemaType instanceof XmlSchemaComplexType) {
                XmlSchemaComplexType complexType = ((XmlSchemaComplexType) schemaType);
                XmlSchemaParticle particle = complexType.getParticle();
                if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) {
                    XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) particle;
                    Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();

                    // now we need to know some information from the binding operation.

                    while (iterator.hasNext()) {
                        XmlSchemaElement innerElement = (XmlSchemaElement) iterator.next();
                        QName qName = innerElement.getQName();
                        if (qName == null && innerElement.getSchemaTypeName()
                                .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
                            createSOAPMessageWithoutSchema(soapFactory, bodyFirstChild, params);
                            break;
                        }
                        long minOccurs = innerElement.getMinOccurs();
                        boolean nillable = innerElement.isNillable();
                        String name = qName != null ? qName.getLocalPart() : innerElement.getName();
                        Object value;
                        OMNamespace ns = (qName == null || qName.getNamespaceURI() == null
                                || qName.getNamespaceURI().length() == 0) ? null
                                        : soapFactory.createOMNamespace(qName.getNamespaceURI(), null);

                        // FIXME changed
                        if ((value = params.get(name)) != null) {
                            addRequestParameter(soapFactory, bodyFirstChild, ns, name, value);
                            minOccurs--;
                        }
                        if (minOccurs > 0) {
                            if (nillable) {

                                OMNamespace xsi = soapFactory.createOMNamespace(
                                        Constants.URI_DEFAULT_SCHEMA_XSI, Constants.NS_PREFIX_SCHEMA_XSI);
                                OMAttribute omAttribute = soapFactory.createOMAttribute("nil", xsi, "true");
                                soapFactory.createOMElement(name, ns, bodyFirstChild).addAttribute(omAttribute);

                            } else {
                                //                                    throw new AxisFault("Required element " + qName +
                                //                                                        " defined in the schema can not be" +
                                //                                                        " found in the request");
                            }
                        }
                    }
                }
            }
        }

    }

    return inEnvlope;

}

From source file:org.apache.axis2.transport.xmpp.XMPPSender.java

/**
 * Retrieves list of parameter names & their type for a given operation
 * @param operation/*from  w  w  w  .  j a va 2 s .c o  m*/
 */
private static String getParameterListForOperation(AxisOperation operation) {
    //Logic copied from BuilderUtil.buildsoapMessage(...)
    StringBuffer paramList = new StringBuffer();
    AxisMessage axisMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    XmlSchemaElement xmlSchemaElement = axisMessage.getSchemaElement();
    if (xmlSchemaElement != null) {
        XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
        if (schemaType instanceof XmlSchemaComplexType) {
            XmlSchemaComplexType complexType = ((XmlSchemaComplexType) schemaType);
            XmlSchemaParticle particle = complexType.getParticle();
            if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) {
                XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) particle;
                Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();

                while (iterator.hasNext()) {
                    XmlSchemaElement innerElement = (XmlSchemaElement) iterator.next();
                    QName qName = innerElement.getQName();
                    if (qName == null && innerElement.getSchemaTypeName()
                            .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
                        break;
                    }
                    long minOccurs = innerElement.getMinOccurs();
                    boolean nillable = innerElement.isNillable();
                    String name = qName != null ? qName.getLocalPart() : innerElement.getName();
                    String type = innerElement.getSchemaTypeName().toString();
                    paramList.append("," + type + " " + name);
                }
            }
        }
    }
    //remove first ","
    String list = paramList.toString();
    return list.replaceFirst(",", "");
}

From source file:org.apache.axis2.util.MessageContextBuilder.java

/**
 * Information to create the SOAPFault can be extracted from different places.
 * 1. Those information may have been put in to the message context by some handler. When someone
 * is putting like that, he must make sure the SOAPElements he is putting must be from the
 * correct SOAP Version./*from  www .  j  a  va2s. co m*/
 * 2. SOAPProcessingException is flexible enough to carry information about the fault. For example
 * it has an attribute to store the fault code. The fault reason can be extracted from the
 * message of the exception. I opted to put the stacktrace under the detail element.
 * eg : <Detail>
 * <Exception> stack trace goes here </Exception>
 * <Detail>
 * <p/>
 * If those information can not be extracted from any of the above places, I default the soap
 * fault values to following.
 * <Fault>
 * <Code>
 * <Value>env:Receiver</Value>
 * </Code>
 * <Reason>
 * <Text>unknown</Text>
 * </Reason>
 * <Role/>
 * <Node/>
 * <Detail/>
 * </Fault>
 * <p/>
 * -- EC
 *
 * @param context
 * @param e
 */
private static SOAPEnvelope createFaultEnvelope(MessageContext context, Throwable e) {
    SOAPEnvelope envelope;

    if (log.isDebugEnabled()) {
        log.debug("start createFaultEnvelope()");
    }
    if (context.isSOAP11()) {
        envelope = OMAbstractFactory.getSOAP11Factory().getDefaultFaultEnvelope();
    } else {
        // Following will make SOAP 1.2 as the default, too.
        envelope = OMAbstractFactory.getSOAP12Factory().getDefaultFaultEnvelope();
    }
    SOAPFault fault = envelope.getBody().getFault();
    SOAPProcessingException soapException = null;
    AxisFault axisFault = null;

    if (e == null)
        return envelope;

    if (e instanceof AxisFault) {
        axisFault = (AxisFault) e;
    } else if (e.getCause() instanceof AxisFault) {
        axisFault = (AxisFault) e.getCause();
    }

    if (axisFault != null) {
        Iterator iter = axisFault.headerIterator();
        while (iter.hasNext()) {
            SOAPHeaderBlock header = (SOAPHeaderBlock) iter.next();
            envelope.getHeader().addChild(header);
        }
    }

    if (e instanceof SOAPProcessingException) {
        soapException = (SOAPProcessingException) e;
    } else if (axisFault != null) {
        if (axisFault.getCause() instanceof SOAPProcessingException) {
            soapException = (SOAPProcessingException) axisFault.getCause();
        }
    }

    // user can set the fault information to the message context or to the AxisFault itself.
    // whatever user sets to the message context, supercedes eerything.

    Object faultCode = context.getProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME);
    String soapFaultCode = "";

    if (faultCode != null) {
        if (log.isDebugEnabled()) {
            log.debug("faultCode != null");
        }
        fault.setCode((SOAPFaultCode) faultCode);
        soapFaultCode = ((SOAPFaultCode) faultCode).getText();
    } else if (soapException != null) {
        if (log.isDebugEnabled()) {
            log.debug("soapException != null");
        }
        soapFaultCode = soapException.getFaultCode();
        OMNamespace namespace = null;
        if (envelope != null) {
            if (log.isDebugEnabled()) {
                log.debug("envelope!=null");
            }
            namespace = envelope.getNamespace();
        }

        if (namespace != null) {
            String sfcLocalPart = soapFaultCode.substring(soapFaultCode.lastIndexOf(":") + 1);

            //If the fault code is one of the predefined ones that make sure the prefix 
            //matches that of the envelope NS
            if (sfcLocalPart.equals(SOAPConstants.FAULT_CODE_VERSION_MISMATCH)
                    || sfcLocalPart.equals(SOAPConstants.FAULT_CODE_MUST_UNDERSTAND)
                    || sfcLocalPart.equals(SOAPConstants.FAULT_CODE_DATA_ENCODING_UNKNOWN)
                    || sfcLocalPart.equals(SOAPConstants.FAULT_CODE_RECEIVER)
                    || sfcLocalPart.equals(SOAPConstants.FAULT_CODE_SENDER)) {

                if (log.isDebugEnabled()) {
                    log.debug("SoapFaultCode local part= " + sfcLocalPart);
                }

                String prefix = namespace.getPrefix() + ":";

                if (!soapFaultCode.contains(":")) {
                    soapFaultCode = prefix + soapFaultCode;
                } else {
                    soapFaultCode = prefix + soapFaultCode.substring(soapFaultCode.indexOf(":") + 1);
                }

                if (log.isDebugEnabled()) {
                    log.debug("SoapFaultCode reset to " + soapFaultCode);
                }

            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Namespace is null, cannot attach prefix to SOAPFaultCode");
            }
        }

        if (log.isDebugEnabled()) {
            log.debug("SoapFaultCode =" + soapFaultCode);
        }

    } else if (axisFault != null) {
        if (log.isDebugEnabled()) {
            log.debug("axisFault != null");
        }
        if (axisFault.getFaultCodeElement() != null) {
            fault.setCode(axisFault.getFaultCodeElement());
            soapFaultCode = axisFault.getFaultCodeElement().getText();
        } else {
            QName faultCodeQName = axisFault.getFaultCode();
            if (faultCodeQName != null) {
                if (log.isDebugEnabled()) {
                    log.debug("prefix =" + faultCodeQName.getPrefix());
                    log.debug("Fault Code namespace =" + faultCodeQName.getNamespaceURI());
                    log.debug("Fault Code =" + faultCodeQName.getLocalPart());
                }
                if (faultCodeQName.getLocalPart().indexOf(":") == -1) {
                    if (log.isDebugEnabled()) {
                        log.debug("faultCodeQName.getLocalPart().indexOf(\":\") == -1");
                    }
                    String prefix = faultCodeQName.getPrefix();
                    if (log.isDebugEnabled()) {
                        log.debug("prefix = " + prefix);
                    }
                    String uri = faultCodeQName.getNamespaceURI();
                    // Get the specified prefix and uri
                    prefix = prefix == null ? "" : prefix;
                    uri = uri == null || "".equals(uri) ? fault.getNamespace().getNamespaceURI() : uri;
                    // Make sure the prefix and uri are declared on the fault, and 
                    // get the resulting prefix.
                    prefix = fault.declareNamespace(uri, prefix).getPrefix();
                    soapFaultCode = prefix + ":" + faultCodeQName.getLocalPart();
                    if (log.isDebugEnabled()) {
                        log.debug("Altered soapFaultCode =" + soapFaultCode);
                    }
                } else {
                    soapFaultCode = faultCodeQName.getLocalPart();
                }
            }
        }
    }

    // defaulting to fault code Receiver, if no message is available
    if (faultCode == null && context.getEnvelope() != null) {
        soapFaultCode = ("".equals(soapFaultCode) || (soapFaultCode == null))
                ? SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":"
                        + context.getEnvelope().getVersion().getReceiverFaultCode().getLocalPart()
                : soapFaultCode;
    }

    if (faultCode == null) {
        if (log.isDebugEnabled()) {
            log.debug("faultCode == null");
        }
        if (context.isSOAP11()) {
            if (log.isDebugEnabled()) {
                log.debug("context.isSOAP11() = true");
                SOAPFaultCode code = (fault != null) ? fault.getCode() : null;
                SOAPFaultValue value = (code != null) ? code.getValue() : null;
                if (value != null) {
                    QName name = value.getQName();
                    log.debug("prefix =" + name.getPrefix());
                    log.debug("Fault Code namespace =" + name.getNamespaceURI());
                    log.debug("Fault Code =" + name.getLocalPart());
                }
            }

            fault.getCode().setText(soapFaultCode);
        } else {
            if (log.isDebugEnabled()) {
                log.debug("context.isSOAP11() = false");
                SOAPFaultCode code = (fault != null) ? fault.getCode() : null;
                SOAPFaultValue value = (code != null) ? code.getValue() : null;
                if (value != null) {
                    QName name = value.getQName();
                    log.debug("prefix =" + name.getPrefix());
                    log.debug("Fault Code namespace =" + name.getNamespaceURI());
                    log.debug("Fault Code =" + name.getLocalPart());
                }
            }
            SOAPFaultValue value = fault.getCode().getValue();
            if (log.isDebugEnabled()) {
                log.debug("soapFaultCode originally was set to : " + soapFaultCode);
            }
            OMNamespace namespace = value.getNamespace();
            soapFaultCode = switchNamespacePrefix(soapFaultCode, namespace);
            value.setText(soapFaultCode);
        }
    }

    if (axisFault != null && !context.isSOAP11()) {
        if (axisFault.getFaultSubCodes() != null) {

            List faultSubCodes = axisFault.getFaultSubCodes();

            QName faultSubCodeQName;

            for (Object faultSubCode : faultSubCodes) {

                faultSubCodeQName = (QName) faultSubCode;

                SOAPFactory sf = (SOAPFactory) envelope.getOMFactory();
                SOAPFaultSubCode soapFaultSubCode = sf.createSOAPFaultSubCode(fault.getCode());
                SOAPFaultValue saopFaultValue = sf.createSOAPFaultValue(fault.getCode());
                saopFaultValue.setText(faultSubCodeQName);
                soapFaultSubCode.setValue(saopFaultValue);
                fault.getCode().setSubCode(soapFaultSubCode);
            }

        }
    }

    SOAPFaultReason faultReason = (SOAPFaultReason) context
            .getProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME);

    if (faultReason == null && axisFault != null) {
        faultReason = axisFault.getFaultReasonElement();
    }
    if (faultReason != null) {
        fault.setReason(faultReason);
    } else {
        String message = "";
        if (soapException != null) {
            message = soapException.getMessage();
        } else if (axisFault != null) {
            // Couldn't find FaultReasonElement, try reason string
            message = axisFault.getReason();
        }

        if (message == null || "".equals(message)) {
            message = getFaultReasonFromException(e, context);
        }

        if (message == null || "".equals(message))
            message = "unknown";

        if (context.isSOAP11()) {
            fault.getReason().setText(message);
        } else {
            fault.getReason().getFirstSOAPText().setLang("en-US");
            fault.getReason().getFirstSOAPText().setText(message);
        }
    }

    Object faultRole = context.getProperty(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME);
    if (faultRole != null) {
        fault.getRole().setText((String) faultRole);
    } else if (axisFault != null) {
        if (axisFault.getFaultRoleElement() != null) {
            fault.setRole(axisFault.getFaultRoleElement());
        }
    }

    Object faultNode = context.getProperty(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME);
    if (faultNode != null) {
        SOAPFaultNode soapFaultNode = fault.getNode();
        if (soapFaultNode != null) {
            soapFaultNode.setText((String) faultNode);
        }
    } else if (axisFault != null) {
        if (axisFault.getFaultNodeElement() != null) {
            fault.setNode(axisFault.getFaultNodeElement());
        }
    }

    // Allow handlers to override the sendStacktraceDetailsWithFaults setting from the Configuration to allow
    // WS-* protocol faults to not include the exception.
    boolean sendStacktraceDetailsWithFaults = false;
    OperationContext oc = context.getOperationContext();
    Object flagFromContext = null;
    if (oc != null) {
        flagFromContext = context.getOperationContext()
                .getProperty(Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS);
    }
    if (flagFromContext != null) {
        sendStacktraceDetailsWithFaults = JavaUtils.isTrue(flagFromContext);
    } else {
        Parameter param = context.getParameter(Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS);
        if (param != null) {
            sendStacktraceDetailsWithFaults = JavaUtils.isTrue(param.getValue());
        }
    }

    Object faultDetail = context.getProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME);
    if (faultDetail != null) {
        fault.setDetail((SOAPFaultDetail) faultDetail);
    } else if (axisFault != null) {
        if (axisFault.getFaultDetailElement() != null) {
            fault.setDetail(axisFault.getFaultDetailElement());
        } else {
            OMElement detail = axisFault.getDetail();
            if (detail != null) {
                fault.getDetail().addDetailEntry(detail);
            } else if (sendStacktraceDetailsWithFaults) {
                fault.setException(axisFault);
            }
        }
    } else if (fault.getException() == null && sendStacktraceDetailsWithFaults) {
        if (e instanceof Exception) {
            fault.setException((Exception) e);
        } else {
            fault.setException(new Exception(e));
        }
    }

    if (log.isDebugEnabled())
        log.debug("End createFaultEnvelope()");
    return envelope;
}

From source file:org.apache.axis2.util.Utils.java

public static AxisService createSimpleInOnlyService(QName serviceName, MessageReceiver messageReceiver,
        QName opName) throws AxisFault {
    AxisService service = new AxisService(serviceName.getLocalPart());
    service.setClassLoader(getContextClassLoader_DoPriv());

    AxisOperation axisOp = new InOnlyAxisOperation(opName);

    axisOp.setMessageReceiver(messageReceiver);
    axisOp.setStyle(WSDLConstants.STYLE_RPC);
    service.addOperation(axisOp);//ww  w. j a  v  a2  s  . c o m
    service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/" + opName.getLocalPart(), axisOp);

    return service;
}

From source file:org.apache.axis2.util.Utils.java

public static AxisService createSimpleService(QName serviceName, MessageReceiver messageReceiver,
        String className, QName opName) throws AxisFault {
    AxisService service = new AxisService(serviceName.getLocalPart());

    service.setClassLoader(getContextClassLoader_DoPriv());
    service.addParameter(new Parameter(Constants.SERVICE_CLASS, className));

    AxisOperation axisOp = new InOutAxisOperation(opName);

    axisOp.setMessageReceiver(messageReceiver);
    axisOp.setStyle(WSDLConstants.STYLE_RPC);
    service.addOperation(axisOp);//from   ww  w.j  a  va2s  .c  om
    service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI + "/" + opName.getLocalPart(), axisOp);

    return service;
}

From source file:org.apache.axis2.util.Utils.java

public static AxisService createSimpleServiceforClient(QName serviceName, MessageReceiver messageReceiver,
        String className, QName opName) throws AxisFault {
    AxisService service = new AxisService(serviceName.getLocalPart());

    service.setClassLoader(getContextClassLoader_DoPriv());
    service.addParameter(new Parameter(Constants.SERVICE_CLASS, className));

    AxisOperation axisOp = new OutInAxisOperation(opName);

    axisOp.setMessageReceiver(messageReceiver);
    axisOp.setStyle(WSDLConstants.STYLE_RPC);
    service.addOperation(axisOp);/*  ww  w  .  j  a  v a 2s  .  co m*/

    return service;
}