Package org.apache.axis.encoding

Examples of org.apache.axis.encoding.Serializer


                containingElement.setAttribute("type", getQNameString(qName));
            return;
        }

        // look up the serializer in the TypeMappingRegistry
        Serializer ser = null;
        SerializerFactory factory = null;
        if (tm != null) {
            factory = (SerializerFactory)tm.getSerializer(type);
        } else {
            factory = (SerializerFactory)defaultTM.getSerializer(type);
        }

        // If no factory is found, use the BeanSerializerFactory
        // if applicable, otherwise issue errors and treat as an anyType
        if (factory == null) {
            if (isEnumClass(type)) {
                factory = new EnumSerializerFactory(type, qName);
            } else if (isBeanCompatible(type, true)) {
                factory = new BeanSerializerFactory(type, qName);
            } else {
                return;
            }
        }

        if (factory != null) {
            ser = (Serializer)factory.getSerializerAs(Constants.AXIS_SAX);
        }

        // if we can't get a serializer, that is bad.
        if (ser == null) {
            throw new AxisFault(
                    Messages.getMessage("NoSerializer00", type.getName()));
        }

        Element typeEl;
        try {
            typeEl = ser.writeSchema(type, this);
        } catch (Exception e) {
            throw AxisFault.makeFault(e);
        }

        // If this is an anonymous type, just make the type element a child
View Full Code Here


    }
   
    protected Serializer getSerializerAsInternal(String mechanismType)
        throws JAXRPCException {
        // Try getting a specialized Serializer
        Serializer serializer = getSpecialized(mechanismType);
       
        // Try getting a general purpose Serializer via constructor
        // invocation
        if (serializer == null) {
            serializer = getGeneralPurpose(mechanismType);
View Full Code Here

            if (tmr == null) {
                tmr = new TypeMappingRegistry();
                registry.addTypeMappingRegistry(mapping.getEncodingStyle(), tmr);
            }

            Serializer ser = null;
            DeserializerFactory deser = null;
           
            try {
                ser = (Serializer)mapping.getSerializer().newInstance();
                deser = (DeserializerFactory)mapping.getDeserializer().newInstance();
View Full Code Here

            return Constants.NS_PREFIX_SOAP_ENC + ":" +
                    qName.getLocalPart();
        }

        // look up the serializer in the TypeMappingRegistry
        Serializer ser = null;
        SerializerFactory factory = null;
        if (tm != null) {
            factory = (SerializerFactory)tm.getSerializer(type);
        } else {
            factory = (SerializerFactory)defaultTM.getSerializer(type);
        }

        // If no factory is found, use the BeanSerializerFactory
        // if applicable, otherwise issue errors and treat as an anyType
        if (factory == null) {
            if (isBeanCompatible(type, true)) {
                factory = new BeanSerializerFactory(type, qName);
            } else {
                return null// Don't return an element name
            }
        }

        if (factory != null) {
            ser = (Serializer)factory.getSerializerAs(Constants.AXIS_SAX);
        }

        // if we can't get a serializer, that is bad.
        if (ser == null) {
            throw new AxisFault(
                    Messages.getMessage("NoSerializer00", type.getName()));
        }

        // Write the namespace
        writeTypeNamespace(type, qName);

        // If an array the component type should be processed first
        String componentTypeName = null;
        Class componentType = null;
        if (type.isArray()) {
            String dimString = "[]";
            componentType = type.getComponentType();
            if (componentType.isArray()) {
                while (componentType.isArray()) {
                    dimString += "[]";
                    componentType = componentType.getComponentType();
                }
            }
            componentTypeName = writeType(componentType, null) + dimString;
        }

        String prefix = namespaces.getCreatePrefix(qName.getNamespaceURI());
        String prefixedName = prefix+":"+qName.getLocalPart();

        // If processed before, or this is a known namespace, return
        if (!addToTypesList(qName))
          return prefixedName;
        if (type.isArray()) {
            // ComplexType representation of array
            Element complexType = docHolder.createElement("complexType");
            writeSchemaElement(qName, complexType);
            complexType.setAttribute("name", qName.getLocalPart());

            Element complexContent = docHolder.createElement("complexContent");
            complexType.appendChild(complexContent);

            Element restriction = docHolder.createElement("restriction");
            complexContent.appendChild(restriction);
            restriction.setAttribute("base",
                                     Constants.NS_PREFIX_SOAP_ENC + ":Array");

            Element attribute = docHolder.createElement("attribute");
            restriction.appendChild(attribute);
            attribute.setAttribute("ref",
                                   Constants.NS_PREFIX_SOAP_ENC +":arrayType");
            attribute.setAttribute(Constants.NS_PREFIX_WSDL +":arrayType",
                                   componentTypeName );
        } else {
            try {
                if (isEnumClass(type)) {
                    writeEnumType(qName, type);
                } else {
                    ser.writeSchema(this);
                }
            } catch (Exception e) {
                throw new AxisFault(Messages.getMessage("writeSchemaProblem00", type.getName()), e);
            }
        }
View Full Code Here

            return Constants.NS_PREFIX_SOAP_ENC + ":" +
                    qName.getLocalPart();
        }

        // look up the serializer in the TypeMappingRegistry
        Serializer ser = null;
        SerializerFactory factory = null;
        if (tm != null) {
            factory = (SerializerFactory)tm.getSerializer(type);
        } else {
            factory = (SerializerFactory)defaultTM.getSerializer(type);
        }

        // If no factory is found, use the BeanSerializerFactory
        // if applicable, otherwise issue errors and treat as an anyType
        if (factory == null) {
            if (isBeanCompatible(type, true)) {
                factory = new BeanSerializerFactory(type, qName);
            } else {
                return null; // Don't return an element name
            }
        }

        if (factory != null) {
            ser = (Serializer)factory.getSerializerAs(Constants.AXIS_SAX);
        }

        // if we can't get a serializer, that is bad.
        if (ser == null) {
            throw new AxisFault(
                    JavaUtils.getMessage("NoSerializer00", type.getName()));
        }

        // Write the namespace
        writeTypeNamespace(type, qName);

        // If an array the component type should be processed first
        String componentTypeName = null;
        Class componentType = null;
        if (type.isArray()) {
            String dimString = "[]";
            componentType = type.getComponentType();
            if (componentType.isArray()) {
                while (componentType.isArray()) {
                    dimString += "[]";
                    componentType = componentType.getComponentType();
                }
            }
            componentTypeName = writeType(componentType, null) + dimString;
        }

        String soapTypeName = qName.getLocalPart();
        String prefix = namespaces.getCreatePrefix(qName.getNamespaceURI());
        String prefixedName = prefix+":"+soapTypeName;

        // If processed before, or this is a known namespace, return
        if (!addToTypesList(qName, soapTypeName))
          return prefixedName;

        if (type.isArray()) {
            // ComplexType representation of array
            Element complexType = docHolder.createElement("complexType");
            writeSchemaElement(qName, complexType);
            complexType.setAttribute("name", soapTypeName);

            Element complexContent = docHolder.createElement("complexContent");
            complexType.appendChild(complexContent);

            Element restriction = docHolder.createElement("restriction");
            complexContent.appendChild(restriction);
            restriction.setAttribute("base",
                                     Constants.NS_PREFIX_SOAP_ENC + ":Array");

            Element attribute = docHolder.createElement("attribute");
            restriction.appendChild(attribute);
            attribute.setAttribute("ref",
                                   Constants.NS_PREFIX_SOAP_ENC +":arrayType");
            attribute.setAttribute(Constants.NS_PREFIX_WSDL +":arrayType",
                                   componentTypeName );
        } else {
            try {
                if (isEnumClass(type)) {
                    writeEnumType(qName, type);
                } else {
                    ser.writeSchema(this);
                }
            } catch (Exception e) {
                throw new AxisFault(JavaUtils.getMessage("writeSchemaProblem00", type.getName()), e);
            }
        }
View Full Code Here

        if (isSimpleSoapEncodingType(type))
            return Constants.NSPREFIX_SOAP_ENC + ":" +
                    getTypeQName(type).getLocalPart();

        // look up the serializer in the TypeMappingRegistry
        Serializer ser = null;
        SerializerFactory factory = null;
        if (tm != null) {
            factory = (SerializerFactory)tm.getSerializer(type);
        } else {
            factory = (SerializerFactory)defaultTM.getSerializer(type);
        }
        if (factory == null) {
            // If no factory is found, try the BeanSerializerFactory if
            // the type is not Throwable.  (There is no mapping for
            // java types that extend Throwable.)
            factory = new BeanSerializerFactory(type, getTypeQName(type));
        }
        if (factory != null) {
            ser = (Serializer)factory.getSerializerAs(Constants.AXIS_SAX);
        }
       
        // if we can't get a serializer, that is bad.
        if (ser == null) {           
            throw new AxisFault(
                    JavaUtils.getMessage("NoSerializer00", type.getName()));
        }
       
          // Write the namespace
        QName qName = writeTypeNamespace(type);

        // If an array the component type should be processed first
        String componentTypeName = null;
        Class componentType = null;
        if (type.isArray()) {
            String dimString = "[]";
            componentType = type.getComponentType();
            if (componentType.isArray()) {
                while (componentType.isArray()) {
                    dimString += "[]";
                    componentType = componentType.getComponentType();
                }
            }
            componentTypeName = writeType(componentType) + dimString;
        }

        String soapTypeName = qName.getLocalPart();
        String prefix = namespaces.getCreatePrefix(qName.getNamespaceURI());
        String prefixedName = prefix+":"+soapTypeName;

        // If processed before, or this is a known namespace, return
        if (!addToTypesList(qName, soapTypeName))
          return prefixedName;

        if (type.isArray()) {
            // ComplexType representation of array
            Element complexType = docHolder.createElement("complexType");
            writeSchemaElement(qName, complexType);
            complexType.setAttribute("name", soapTypeName);

            Element complexContent = docHolder.createElement("complexContent");
            complexType.appendChild(complexContent);

            Element restriction = docHolder.createElement("restriction");
            complexContent.appendChild(restriction);
            restriction.setAttribute("base",
                                     Constants.NSPREFIX_SOAP_ENC + ":Array");

            Element attribute = docHolder.createElement("attribute");
            restriction.appendChild(attribute);
            attribute.setAttribute("ref",
                                   Constants.NSPREFIX_SOAP_ENC +":arrayType");
            attribute.setAttribute(Constants.NSPREFIX_WSDL +":arrayType",
                                   componentTypeName );
        } else {
            if (isEnumClass(type)) {
                writeEnumType(qName, type);
            } else {
                ser.writeSchema(this);
            }
        }
        return prefixedName;
    }
View Full Code Here

    }

    public static String objToXml(Object obj)
      throws IllegalArgumentException, IOException {
        QName qn;
        Serializer s;
        if(obj instanceof  SearchRetrieveRequestType) {
            qn=new QName("http://www.loc.gov/zing/srw/", "searchRetrieveRequest");
            s=SearchRetrieveRequestType.getSerializer(
                null, obj.getClass(), qn);
        }
        else if(obj instanceof  SearchRetrieveResponseType) {
            qn=new QName("http://www.loc.gov/zing/srw/", "searchRetrieveResponse");
            s=SearchRetrieveResponseType.getSerializer(
                null, obj.getClass(), qn);
        }
        else if(obj instanceof  ScanRequestType) {
            qn=new QName("http://www.loc.gov/zing/srw/", "scanRequest");
            s=ScanRequestType.getSerializer(
                null, obj.getClass(), qn);
        }
        else if(obj instanceof  ScanResponseType) {
            qn=new QName("http://www.loc.gov/zing/srw/", "scanResponse");
            s=ScanResponseType.getSerializer(
                null, obj.getClass(), qn);
        }
        else throw new IllegalArgumentException(
            "Unrecognized object: "+obj.getClass().getName());

        StringWriter xmlWriter=new StringWriter();
        s.serialize(qn, null, obj, new SerializationContext(xmlWriter));
        return xmlWriter.toString();
    }
View Full Code Here

            return true;
        }

        // look up the serializer in the TypeMappingRegistry
        Serializer ser = null;
        SerializerFactory factory = null;

        if (tm != null) {
            factory = (SerializerFactory) tm.getSerializer(type, qName);
        } else {
            factory = (SerializerFactory) defaultTM.getSerializer(type, qName);
        }

        // If no factory is found, use the BeanSerializerFactory
        // if applicable, otherwise issue errors and treat as an anyType
        if (factory == null) {
            if (isEnumClass(type)) {
                factory = new EnumSerializerFactory(type, qName);
            } else if (isBeanCompatible(type, true)) {
                factory = new BeanSerializerFactory(type, qName);
            } else {
                return false;
            }
        }

        if (factory != null) {
            ser = (Serializer) factory.getSerializerAs(Constants.AXIS_SAX);
        }

        // if we can't get a serializer, that is bad.
        if (ser == null) {
            throw new AxisFault(Messages.getMessage("NoSerializer00",
                    type.getName()));
        }

        Element typeEl;

        try {
            typeEl = ser.writeSchema(type, this);
        } catch (Exception e) {
            throw AxisFault.makeFault(e);
        }

        // If this is an anonymous type, just make the type element a child
View Full Code Here

    }
   
    protected Serializer getSerializerAsInternal(String mechanismType)
        throws JAXRPCException {
        // Try getting a specialized Serializer
        Serializer serializer = getSpecialized(mechanismType);
       
        // Try getting a general purpose Serializer via constructor
        // invocation
        if (serializer == null) {
            serializer = getGeneralPurpose(mechanismType);
View Full Code Here

            if (tmr == null) {
                tmr = new TypeMappingRegistry();
                registry.addTypeMappingRegistry(mapping.getEncodingStyle(), tmr);
            }

            Serializer ser = null;
            DeserializerFactory deser = null;
           
            try {
                ser = (Serializer)mapping.getSerializer().newInstance();
                deser = (DeserializerFactory)mapping.getDeserializer().newInstance();
View Full Code Here

TOP

Related Classes of org.apache.axis.encoding.Serializer

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.