Serializer.toXML() requires unnecessary parent element with specified QName
---------------------------------------------------------------------------

                 Key: MUSE-215
                 URL: https://issues.apache.org/jira/browse/MUSE-215
             Project: Muse
          Issue Type: Bug
         Environment: Muse 2.2.0, JDK 1.5.0
            Reporter: Vinh Nguyen
         Assigned To: Dan Jemiolo


The issue applies to all Muse releases so far.

I have this Get operation defined as:
    <xs:element name="Get_queryName" type="xs:string"/>
    <xs:element name="Get_arguments" type="tns:PropertyNameAndStringValueType"/>
    <xs:element name="Get">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="tns:Get_queryName" minOccurs="1" 
maxOccurs="1"/>
                <xs:element ref="tns:Get_arguments" minOccurs="0" 
maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

The java method is:
public String get(String queryName, PropertyNameAndStringValueType[] queryArgs)

There is an issue with the Serializer.toXML(Object, QName) method.  It requires 
the Element returned to have the QName specified in the parameter.  This forces 
my code to create a parent element with that QName, and then set the real xml 
element as the child.  This causes an unnecessary xml layer on the data, which 
the fromXML() method must strip away to get at the real data.

The effect is two problems:
1) When an array of PropertyNameAndStringValueType objects is sent, each object 
is wrapped in a parent element with the QName passed into toXML() by Muse. The 
result is no longer a list of PropertyNameAndStringValueType objects, but a 
list of <Get_arguments> objects.
2) The dependency on toXML() to add an extra element wrapper and fromXML() to 
strip the wrapper, requires all clients to use the custom serializers.  
Otherwise, if a client sends a properly formatted xml request without the 
unnecessary list wrappers, and the server calls fromXML() to strip expected 
wrappers, data will be lost and errors will occur.

For example, I expected my client output to have one <Get_arguments> containing 
a list of <PropertyNameAndStringValueType> elements like this:

    <soap:Body>
        <pfx1:Get xmlns:pfx1="http://schemas.cisco.com/Query";>
            <pfx1:Get_queryName>TestQueryName</pfx1:Get_queryName>
            <pfx1:Get_arguments>
                    <quer:PropertyNameAndStringValue 
xmlns:quer="http://schemas.cisco.com/Query";>
                        <quer:propertyName>PropertyName 1</quer:propertyName>
                        <quer:stringValue>String value 1</quer:stringValue>
                    </quer:PropertyNameAndStringValue>
                    <quer:PropertyNameAndStringValue 
xmlns:quer="http://schemas.cisco.com/Query";>
                        <quer:propertyName>PropertyName 2</quer:propertyName>
                        <quer:stringValue>String value 2</quer:stringValue>
                    </quer:PropertyNameAndStringValue>
            </pfx1:Get_arguments>
        </pfx1:Get>
    </soap:Body>

But instead, I get one <Get_arguments> containing a list of other 
<Get_arguments> elements:

    <soap:Body>
        <pfx1:Get xmlns:pfx1="http://schemas.cisco.com/Query";>
            <pfx1:Get_queryName>TestQueryName</pfx1:Get_queryName>
            <pfx1:Get_arguments>
                <pfx1:Get_arguments>
                    <quer:PropertyNameAndStringValue 
xmlns:quer="http://schemas.cisco.com/Query";>
                        <quer:propertyName>PropertyName 1</quer:propertyName>
                        <quer:stringValue>String value 1</quer:stringValue>
                    </quer:PropertyNameAndStringValue>
                </pfx1:Get_arguments>
                <pfx1:Get_arguments>
                    <quer:PropertyNameAndStringValue 
xmlns:quer="http://schemas.cisco.com/Query";>
                        <quer:propertyName>PropertyName 2</quer:propertyName>
                        <quer:stringValue>String value 2</quer:stringValue>
                    </quer:PropertyNameAndStringValue>
                </pfx1:Get_arguments>
            </pfx1:Get_arguments>
        </pfx1:Get>
    </soap:Body>

Attached is my test program.


-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to