axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hugo Hallman (JIRA)" <axis-...@ws.apache.org>
Subject [jira] Created: (AXIS-2625) BeanSerializer ignores namespace of arguments
Date Tue, 06 Feb 2007 14:58:05 GMT
BeanSerializer ignores namespace of arguments
---------------------------------------------

                 Key: AXIS-2625
                 URL: https://issues.apache.org/jira/browse/AXIS-2625
             Project: Axis
          Issue Type: Bug
          Components: Serialization/Deserialization
    Affects Versions: 1.4
         Environment: any, server is not Axis.
            Reporter: Hugo Hallman


When calling a web-service with parameter complex types in a different namespace than the
service itself, the BeanSerializer does not set the namespace of the parameter attributes
to that of the parameter type, but leaves the namespace to the namespace of the service, on
the server side, the parameters will be parsed as null.

Example code
javax.xml.rpc.Service service;
service.getTypeMappingRegistry().getDefaultTypeMapping().register(ArgumentType.class, "qn-other-than-service's-qname",
new BeanSerializerFactory(ArgumentType.class, qn), new BeanDeserializerFactory(ArgumentType.class,
qn));


The problem was encountered on Axis 1.3, but looks to be the same on Axis 1.4 and on trunk:
http://svn.apache.org/repos/asf/webservices/axis/trunk/java/src/org/apache/axis/encoding/ser/BeanSerializer.java

This can be patched with a change in org.apache.axis.encoding.ser.BeanSerializer.java.
I have not tested that this suggestion does not break something else, but it solves the problem
for me.

BeanSerializer is in serialize():178

From:
if (qname == null) {
     qname = new QName(isEncoded ? "" : name.getNamespaceURI(),
                        propName);
}

To:
if (qname == null) {
      qname = new QName(isEncoded ? "" : this.xmlType.getNamespaceURI(),
                         propName);
}



Similar problems have been reported here:
https://issues.apache.org/jira/browse/AXIS-2431
https://issues.apache.org/jira/browse/AXIS-2449
https://issues.apache.org/jira/browse/AXIS-2578
https://issues.apache.org/jira/browse/AXIS-1926
https://issues.apache.org/jira/browse/AXIS-2260


This is the XML that is generated to go on the wire.

Incorrect:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Body>
	<doSomething
			xmlns="http://interfaces.api.company.com">
		<in0>
			<contentItem>
				<title>Test Content Item</title>
			</contentItem>
			<domain>testdomain</domain>
		</in0>
	</doSomething>
	</soapenv:Body>
</soapenv:Envelope>

Correct:
(Note the setting of elements in the argument type to ns:http://model.api.company.com)

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Body>
	<doSomething
		xmlns="http://interfaces.api.company.com">
		<in0>
			<ns1:contentItem
				xmlns:ns1="http://model.api.company.com">
				<ns1:title>Test Content Item</ns1:title>
			</ns1:contentItem>
			<ns2:domain
				xmlns:ns2="http://model.api.company.com">
				testdomain
			</ns2:domain>
		</in0>
	</doSomething>
	</soapenv:Body>
</soapenv:Envelope>






WORKAROUND:
In the call to service.getTypeMappingRegistry().getDefaultTypeMapping().register(), give a
reference to the FixedBeanSerializerFactory, and 
copy the from http://svn.apache.org/repos/asf/webservices/axis/trunk/java/src/org/apache/axis/encoding/ser/BeanSerializer.java

to FixedBeanSerializer where the above mentioned patch can be applied.
This solution works with XFire, and should also be appropriate for .net.

    /**
     * Creates a bugfixed serializer.
     */
    static class FixedBeanSerializerFactory extends BeanSerializerFactory {
        private static final long serialVersionUID = -8850895971122182792L;

        /**
         * Creates a new instance of <code>FixedBeanSerializerFactory</code>.
         * @param javaType
         * @param xmlType
         */
        public FixedBeanSerializerFactory(Class javaType, QName xmlType) {
            super(javaType, xmlType);
        }

        /**
         * Optimize construction of a BeanSerializer by caching the
         * type and property descriptors.
         */
        protected Serializer getGeneralPurpose(String mechanismType) {
            if ((javaType == null) || (xmlType == null)) {
                return super.getGeneralPurpose(mechanismType);
            }

            if (serClass == EnumSerializer.class) {
                return super.getGeneralPurpose(mechanismType);
            }

            return new FixedBeanSerializer(javaType, xmlType, typeDesc,
                propertyDescriptor);
        }
    }



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message