Package org.apache.axis.soap

Examples of org.apache.axis.soap.SOAPConstants


        }
                       
        // Look up this element in our faultMap
        // if we find a match, this element is the fault data
        MessageContext msgContext = context.getMessageContext();
        SOAPConstants soapConstants = msgContext.getSOAPConstants();
        OperationDesc op = msgContext.getOperation();
        Class faultClass = null;
        QName faultXmlType = null;
        if (op != null) {
            FaultDesc faultDesc = null;
            // allow fault type to be denoted in xsi:type
            faultXmlType = context.getTypeFromAttributes(namespace,
                                                         name,
                                                         attributes);
            if (faultXmlType != null) {
                faultDesc = op.getFaultByXmlType(faultXmlType);
            }

            // If we didn't get type information, look up QName of fault
            if (faultDesc == null) {
                faultDesc = op.getFaultByQName(qn);
                if ((faultXmlType == null) && (faultDesc != null)) {
                    faultXmlType = faultDesc.getXmlType();
                }
            }

            // Set the class if we found a description
            if (faultDesc != null) {
                try {
                    faultClass = ClassUtils.forName(faultDesc.getClassName());
                } catch (ClassNotFoundException e) {
                    // Just create an AxisFault, no custom exception
                }
            }
        } else {
            faultXmlType = context.getTypeFromAttributes(namespace,
                                                       name,
                                                       attributes);
        }

        if (faultClass == null) {
            faultClass =
                    context.getTypeMapping().getClassForQName(faultXmlType);
        }
       
        if(faultClass != null && faultXmlType != null) {
            builder.setFaultClass(faultClass);
            builder.setWaiting(true);
            // register callback for the data, use the xmlType from fault info
            Deserializer dser = null;
            if (attributes.getValue(soapConstants.getAttrHref()) == null) {
                dser = context.getDeserializerForType(faultXmlType);
            } else {
                dser = new DeserializerImpl();
                dser.setDefaultType(faultXmlType);
            }
View Full Code Here


        MessageElement curEl = context.getCurElement();
        QName type = null;
        QName qname = new QName(namespace, localName);
        ParameterDesc paramDesc = null;

        SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
        if (soapConstants == SOAPConstants.SOAP12_CONSTANTS &&
            Constants.QNAME_RPC_RESULT.equals(qname)) {
            // TODO: fix it ... now we just skip it
            return new DeserializerImpl();
        }
View Full Code Here

    public void startElement(String namespace, String localName,
                             String prefix, Attributes attributes,
                             DeserializationContext context)
        throws SAXException
    {
        SOAPConstants soapConstants = Constants.DEFAULT_SOAP_VERSION;
        if (context.getMessageContext() != null)
            soapConstants = context.getMessageContext().getSOAPConstants();


        if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
View Full Code Here

                context.pushNewElement(myElement);
            }
        }
//        super.startElement(namespace, localName, qName, attributes, context);

        SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();

        QName type = context.getTypeFromAttributes(namespace,
                                                   localName,
                                                   attributes);
        if (log.isDebugEnabled()) {
            log.debug(Messages.getMessage("gotType00", "Deser", "" + type));
        }
       
        String href = attributes.getValue(soapConstants.getAttrHref());
        if (href != null) {
            Object ref = context.getObjectByRef(href);
            try{
                ref = AttachmentUtils.getActivationDataHandler((org.apache.axis.Part)ref);
            }catch(org.apache.axis.AxisFault e){;}
View Full Code Here

            }

            // Set the encoding style to the attribute value.  If null,
            // we just automatically use our parent's (see getEncodingStyle)
            MessageContext mc = context.getMessageContext();
            SOAPConstants sc = (mc != null) ?
                                            mc.getSOAPConstants() :
                                            SOAPConstants.SOAP11_CONSTANTS;

            href = attributes.getValue(sc.getAttrHref());

            // If there's an arrayType attribute, we can pretty well guess that we're an Array???
            if (attributes.getValue(Constants.URI_DEFAULT_SOAP_ENC, Constants.ATTR_ARRAY_TYPE) != null)
                typeQName = Constants.SOAP_ARRAY;


            encodingStyle =
                    attributes.getValue(sc.getEncodingURI(),
                                        Constants.ATTR_ENCODING_STYLE);

            // if no-encoding style was defined, we don't define as well
            if (Constants.URI_SOAP12_NOENC.equals(encodingStyle))
                encodingStyle = null;

            // If we have an encoding style, and are not a MESSAGE style
            // operation (in other words - we're going to do some data
            // binding), AND we're SOAP 1.2, check the encoding style against
            // the ones we've got type mappings registered for.  If it isn't
            // registered, throw a DataEncodingUnknown fault as per the
            // SOAP 1.2 spec.
            if (encodingStyle != null &&
                    sc.equals(SOAPConstants.SOAP12_CONSTANTS) &&
                    (mc.getOperationStyle() != Style.MESSAGE)) {
                TypeMapping tm = mc.getTypeMappingRegistry().
                        getTypeMapping(encodingStyle);
                if (tm == null ||
                        (tm.equals(mc.getTypeMappingRegistry().
View Full Code Here

         * Write the encoding style attribute IF it's different from
         * whatever encoding style is in scope....
         */
        if (encodingStyle != null) {
            MessageContext mc = context.getMessageContext();
            SOAPConstants soapConstants = (mc != null) ?
                                            mc.getSOAPConstants() :
                                            SOAPConstants.SOAP11_CONSTANTS;
            if (parent == null) {
                // don't emit an encoding style if its "" (literal)
                if (!encodingStyle.equals("")) {
                    setAttribute(soapConstants.getEnvelopeURI(),
                                 Constants.ATTR_ENCODING_STYLE,
                                 encodingStyle);
                }
            } else if (!encodingStyle.equals(parent.getEncodingStyle())) {
                setAttribute(soapConstants.getEnvelopeURI(),
                             Constants.ATTR_ENCODING_STYLE,
                             encodingStyle);
            }
        }

View Full Code Here

        if (value == null)
            throw new IOException(Messages.getMessage("cantDoNullArray00"));

        MessageContext msgContext = context.getMessageContext();
        SchemaVersion schema = SchemaVersion.SCHEMA_2001;
        SOAPConstants soap = SOAPConstants.SOAP11_CONSTANTS;
        boolean encoded = true;
       
        if (msgContext != null) {
            encoded = msgContext.isEncoded();
            schema = msgContext.getSchemaVersion();
            soap = msgContext.getSOAPConstants();
        }

        Class cls = value.getClass();
        Collection list = null;

        if (!cls.isArray()) {
            if (!(value instanceof Collection)) {
                throw new IOException(
                        Messages.getMessage("cantSerialize00", cls.getName()));
            }
            list = (Collection)value;
        }

        // Get the componentType of the array/list
        Class componentType;
        if (list == null) {
            componentType = cls.getComponentType();
        } else {
            componentType = Object.class;
        }


        // Check to see if componentType is also an array.
        // If so, set the componentType to the most nested non-array
        // componentType.  Increase the dims string by "[]"
        // each time through the loop.
        // Note from Rich Scheuerle:
        //    This won't handle Lists of Lists or
        //    arrays of Lists....only arrays of arrays.
        String dims = "";
        while (componentType.isArray()) {
            componentType = componentType.getComponentType();
            if (soap == SOAPConstants.SOAP12_CONSTANTS)
                dims += "* ";
            else
                dims += "[]";
        }

        // Get the QName of the componentType.
        // If not found, look at the super classes
        QName componentQName = context.getCurrentXMLType();
        if (componentQName != null) {
            if ((componentQName.equals(xmlType) ||
                    componentQName.equals(soap.getArrayType()))) {
                componentQName = null;
            }
        }
       
        if (componentQName == null) {
            componentQName = context.getQNameForClass(componentType);
        }

        if (componentQName == null) {
            Class searchCls = componentType;
            while(searchCls != null && componentQName == null) {
                searchCls = searchCls.getSuperclass();
                componentQName = context.getQNameForClass(searchCls);
            }
            if (componentQName != null) {
                componentType = searchCls;
            }
        }

        if (componentQName == null) {
            throw new IOException(
                    Messages.getMessage("noType00", componentType.getName()));
        }

        int len = (list == null) ? Array.getLength(value) : list.size();
        String arrayType = "";
        int dim2Len = -1;
        if (encoded) {
            if (soap == SOAPConstants.SOAP12_CONSTANTS)
                arrayType = dims + len;
            else
                arrayType = dims + "[" + len + "]";

            // Discover whether array can be serialized directly as a two-dimensional
            // array (i.e. arrayType=int[2,3]) versus an array of arrays.
            // Benefits:
            //   - Less text passed on the wire.
            //   - Easier to read wire format
            //   - Tests the deserialization of multi-dimensional arrays.
            // Drawbacks:
            //   - Is not safe!  It is possible that the arrays are multiply
            //     referenced.  Transforming into a 2-dim array will cause the
            //     multi-referenced information to be lost.  Plus there is no
            //     way to determine whether the arrays are multi-referenced.
            //   - .NET currently (Dec 2002) does not support 2D SOAP-encoded arrays
            //
            // OLD Comment as to why this was ENABLED:
            // It is necessary for
            // interoperability (echo2DStringArray).  It is 'safe' for now
            // because Axis treats arrays as non multi-ref (see the note
            // in SerializationContextImpl.isPrimitive(...) )
            // More complicated processing is necessary for 3-dim arrays, etc.
            //
            // Axis 1.1 - December 2002
            // Turned this OFF because Microsoft .NET can not deserialize
            // multi-dimensional SOAP-encoded arrays, and this interopability
            // is pretty high visibility. Make it a global configuration parameter:
            //  <parameter name="enable2DArrayEncoding" value="true"/>    (tomj)
            //

            // Check the message context to see if we should turn 2D processing ON
            // Default is OFF
            boolean enable2Dim = false;
       
            // Vidyanand : added this check
            if( msgContext != null ) {
               enable2Dim = JavaUtils.isTrueExplicitly(msgContext.getProperty(
                       AxisEngine.PROP_TWOD_ARRAY_ENCODING));
            }

            if (enable2Dim && !dims.equals("")) {
                if (cls.isArray() && len > 0) {
                    boolean okay = true;
                    // Make sure all of the component arrays are the same size
                    for (int i=0; i < len && okay; i++) {

                        Object elementValue = Array.get(value, i);
                        if (elementValue == null)
                            okay = false;
                        else if (dim2Len < 0) {
                            dim2Len = Array.getLength(elementValue);
                            if (dim2Len <= 0) {
                                okay = false;
                            }
                        } else if (dim2Len != Array.getLength(elementValue)) {
                            okay = false;
                        }
                    }
                    // Update the arrayType to use mult-dim array encoding
                    if (okay) {
                        dims = dims.substring(0, dims.length()-2);
                        if (soap == SOAPConstants.SOAP12_CONSTANTS)
                            arrayType = dims + len + " " + dim2Len;
                        else
                            arrayType = dims + "[" + len + "," + dim2Len + "]";
                    } else {
                        dim2Len = -1;
                    }
                }
            }
        }

        // Need to distinguish if this is array processing for an
        // actual schema array or for a maxOccurs usage.
        // For the maxOccurs case, the currentXMLType of the context is
        // the same as the componentQName.
        boolean maxOccursUsage = !encoded &&
                componentQName.equals(context.getCurrentXMLType());

        if (encoded) {
            AttributesImpl attrs;
            if (attributes == null) {
                attrs = new AttributesImpl();
            } else if (attributes instanceof AttributesImpl) {
                attrs = (AttributesImpl)attributes;
            } else {
                attrs = new AttributesImpl(attributes);
            }

            String compType = context.attributeQName2String(componentQName);

            if (attrs.getIndex(soap.getEncodingURI(), soap.getAttrItemType()) == -1) {
                String encprefix =
                       context.getPrefixForURI(soap.getEncodingURI());

                if (soap != SOAPConstants.SOAP12_CONSTANTS) {
                    compType = compType + arrayType;
                   
                    attrs.addAttribute(soap.getEncodingURI(),
                                       soap.getAttrItemType(),
                                       encprefix + ":arrayType",
                                       "CDATA",
                                       compType);

                } else {
                    attrs.addAttribute(soap.getEncodingURI(),
                                       soap.getAttrItemType(),
                                       encprefix + ":itemType",
                                       "CDATA",
                                       compType);

                    attrs.addAttribute(soap.getEncodingURI(),
                                       "arraySize",
                                       encprefix + ":arraySize",
                                       "CDATA",
                                   arrayType);
                }
View Full Code Here

                    body.getName());
            operation = serviceDesc.getOperationByElementQName(qname);
        }

        if (operation == null) {
            SOAPConstants soapConstants = msgContext == null ?
                    SOAPConstants.SOAP11_CONSTANTS :
                    msgContext.getSOAPConstants();
            if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
                AxisFault fault =
                        new AxisFault(Constants.FAULT_SOAP12_SENDER,
View Full Code Here

    /**
     * returns the soap constants.
     */
    private SOAPConstants getSOAPConstants(){
        SOAPConstants constants = Constants.DEFAULT_SOAP_VERSION;
        if(msgContext != null)
            constants = msgContext.getSOAPConstants();
        return constants;
    }
View Full Code Here

        if (attributes == null || attributes.getLength() == 0) {
            attributes = NullAttributes.singleton;
        } else {
            attributes = new AttributesImpl(attributes);

            SOAPConstants soapConstants = getSOAPConstants();
            if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
                if (attributes.getValue(soapConstants.getAttrHref()) != null &&
                    attributes.getValue(Constants.ATTR_ID) != null) {

                    AxisFault fault = new AxisFault(Constants.FAULT_SOAP12_SENDER,
                        null, Messages.getMessage("noIDandHREFonSameElement"), null, null, null);
View Full Code Here

TOP

Related Classes of org.apache.axis.soap.SOAPConstants

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.