ReflectionMessageHandler sends bad XML when handling complex return type
containing multiple child elements
-----------------------------------------------------------------------------------------------------------
Key: MUSE-248
URL: https://issues.apache.org/jira/browse/MUSE-248
Project: Muse
Issue Type: Bug
Reporter: Vinh Nguyen
Assignee: Dan Jemiolo
I have the following operation response defined:
<xs:element name="EnumerateResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Expires" type="tns:ExpirationType"
minOccurs="0"/>
<xs:element name="EnumerationContext"
type="tns:EnumerationContextType"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
This type has multiple child elements, so I have to define my operation to
return the full response itself:
public EnumerateResponse enumerate(..)
But, the resulting XML is badly nested:
<soapenv:Body>
<muse-op:EnumerateResponse
xmlns:muse-op="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
xmlns:tns="http://axis2.platform.core.muse.apache.org">
<muse-op:Expires
xmlns:enum="http://schemas.xmlsoap.org/ws/2004/09/enumeration">
<enum:Expires>2007-07-12T20:12:02.544-07:00</enum:Expires>
<enum:EnumerationContext/>
</muse-op:Expires>
</muse-op:EnumerateResponse>
</soapenv:Body>
The reason is because Muse assumes an operation will return an object that does
NOT contain the response wrapper itself. In my case, I have to return the
entire wrapper with its child elements because I can't just return an array of
just the child objects.
So Muse is doing the following:
1) Take the QName of the first child element defined in the response in the
wsdl. This will be the name of the operation return type.
2) Passes this QName into mySerializer.toXML(Object,QName). So here, Muse will
pass the QName of the "Expires" child element.
3) After my serializer converts the Object to an Element, it must switch the
QName from "EnumerateResponse" to "Expires", and return it.
4) Finally, Muse creates an empty EnumerateResponse element wrapper, and adds
my serializer.toXML() result as the child element.
The result is badly nested XML sent to the client as you can see above.
I traversed the Muse code, and the error seems to be with the logic in several
areas:
1) SimpleResourceDescriptor.createMessageHandler() - creates default
ReflectionMessageHandler using request/response names determined by WsdlUtils
2) ReflectionMessageHandler.toXML() - always creates an empty response wrapper,
and sets a complex type operation result as the child
3) WsdlUtils.getOutputPartName() - always returns the QName of the first child
element of the response type, as the name of the operation result
I realize this is probably why Muse has its own custom MessageHandler for many
of its operations (i.e. Subscribe handler for the notification producer
Subscribe operation), instead of using the default ReflectionMessageHandler.
The only way around this is to also implement my own MessageHandler for each
operation that returns a result type that contains multiple child elements.
But, this makes development/maintenance very cumbersome, not to mention the
overhead during runtime with so many objects created per operation.
--
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]