Hi Dan, I don't have a Tomcat server debugger setup, so it's hard for me to trace the server code. What object creates the ReflectionMessageHandler? Also, what object calls ReflectionMessageHandler.toXml()? I want to trace where the "returnValueName" and "responseBodyName" values in this method are coming from, and what they are, since they are being passed to serializer.toXml(). I suspect this might pinpoint the cause of this issue a bit further.
I tested an implemention of a custom serializer for another custom Car object. When my CarTypeSerializer.toXml() is called (and I assume from the default ReflectionMessageHandler), the second parameter is a QName containing the incorrect namespace: http://schemas.xmlsoap.org/wsdl/}Car The "http://schemas.xmlsoap.org/wsdl" namespace value seems to be coming from the xmlns="http://schemas.xmlsoap.org/wsdl/" attribute defined in the wsdl. The result is an element with everything correct except the namespace of the topmost element: --CarTypeSerializer.toXml() Printing XmlUtils.toString(response): <?xml version="1.0" encoding="UTF-8"?> <Car xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:car="http://cisco.com/musebox/schemas/car"> <car:make xmlns:car="http://cisco.com/musebox/schemas/car">Honda</car:make> <car:model xmlns:car="http://cisco.com/musebox/schemas/car">Accord</car:model> <car:color xmlns:car="http://cisco.com/musebox/schemas/car">White</car:color> </Car> The problem seems to be near where the serializer is called on the server side. This occurs after the capability method is called, and before the serialized xml result it sent to the client. So somewhere in Muse even before the data is sent thru Axis2. Hence, when CarTypeSerializer.fromXml() is called on the client side, it also runs into the same issues with the xml it receives. -----Original Message----- From: Dan Jemiolo (JIRA) [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 8:43 PM To: [email protected] Subject: [jira] Commented: (MUSE-155) xml element capability result improperly changed when passed to the client (namespace and prefix not preserved) [ http://issues.apache.org/jira/browse/MUSE-155?page=comments#action_12454 531 ] Dan Jemiolo commented on MUSE-155: ---------------------------------- I still think this is Axis2, not Muse. First, I can't find anywhere in the code where we set the WSDL/SOAP binding namespace, for any reason. Second, I can't find anywhere in the code where we modify the namespaces on the element returned to us by Resource.invoke(). Finally, the ReflectionMessageHandler, which wraps your response element in the wrapper, has the following code: // // for complex types, we need a child element under the // response body element // Element valueXML = ser.toXML(result, returnValueName); // // for arrays, we put the children (array items) under the // response body element // if (returnType.isArray()) XmlUtils.moveSubTree(valueXML, responseXML); else if (isComplex) responseXML.appendChild(valueXML); else responseXML = valueXML; return responseXML; So, the ElementSerializer.toXML() method is called (which does nothing -just returns the given Element), and since your type is not an array, and is complex, the Element is appended to the wrapper. Then it is returned. After the above return statement, it's all pass throughs - giving the Element back to the isolation layer for return to the Axis2 engine. > xml element capability result improperly changed when passed to the > client (namespace and prefix not preserved) > ---------------------------------------------------------------------- > ----------------------------------------- > > Key: MUSE-155 > URL: http://issues.apache.org/jira/browse/MUSE-155 > Project: Muse > Issue Type: Bug > Affects Versions: 2.0.0 > Environment: Muse 2.0.0, Axis2 1.0, Apache 2.2.3, Tomcat 5.5.17, JDK 1.5.0_08, Windows XP SP2 > Reporter: Vinh Nguyen > Assigned To: Dan Jemiolo > > Muse is improperly changing the xml result of operations that return custom types. > For example, my code returns a custom <Box> type in an xml Element. On the pass back to the client, Muse wraps the Element in a response wrapper. In doing so, it improperly changes/deletes my element's namespace and prefix. This causes problems on the client side when I try to extract out my element and deserialize back to a javabean. The original namespace was moved/deleted and a default one was inserted, so it becomes difficult to extract the original element, and my code encounters errors due to mismatched namespaces. > Here's my server code: > public Element boxOperation(int width) throws Exception > { > BoxDocument doc = BoxDocument.Factory.newInstance(); > BoxType type = doc.addNewBox(); > type.setWidth(BigInteger.valueOf(width)); > type.setHeight(BigInteger.valueOf(width)); > Element response = XmlUtils.getFirstElement(doc.newDomNode()); > System.out.println("--BoxCapability toString(response):\n" + XmlUtils.toString(response)); > return response; > } > Here's the server log output: > --BoxCapability toString(response): > <?xml version="1.0" encoding="UTF-8"?> > <box:Box xmlns:box="http://cisco.com/musebox/schemas/box"> > <box:width>555</box:width> > <box:height>555</box:height> > </box:Box> > On the client side, here's the SOAP trace of the incoming data: > [CLIENT TRACE] SOAP envelope contents (incoming): > ... > <soapenv:Body> > <muse-op:BoxOperationResponse > xmlns:muse-op="http://cisco.com/musebox/simple/box" xmlns:tns="http://ws.apache.org/axis2"> > <Box xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:box="http://cisco.com/musebox/schemas/box"> > <box:width>555</box:width> > <box:height>555</box:height> > </Box> > </muse-op:BoxOperationResponse> > </soapenv:Body> > </soapenv:Envelope> > If I modify my wsdl and remove one attribute line > (xmlns="http://schemas.xmlsoap.org/wsdl/") at the top of the file, I get the following client side SOAP trace instead: > [CLIENT TRACE] SOAP envelope contents (incoming): > ... > <soapenv:Body> > <muse-op:BoxOperationResponse > xmlns:muse-op="http://cisco.com/musebox/simple/box" xmlns:tns="http://ws.apache.org/axis2"> > <Box xmlns:box="http://cisco.com/musebox/schemas/box"> > <box:width>555</box:width> > <box:height>555</box:height> > </Box> > </muse-op:BoxOperationResponse> > </soapenv:Body> > </soapenv:Envelope> > NOTE: The difference between the two traces are the namespaces in the <Box> element. > If my client code calls XmlUtils.toString(XmlUtils.getFirstElement(response)), I get: > <?xml version="1.0" encoding="UTF-8"?> > <Box xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:box="http://cisco.com/musebox/schemas/box"> > <box:width>555</box:width> > <box:height>555</box:height> > </Box> > So there are 2 problems here: > 1) Muse takes my operation output and puts on a response wrapper. In doing so, it removes both the namespace and prefix of the <Box> element. > After removing the wrapper, the <Box> element now becomes useless because it has no namespace, even though namespaces for child elements are properly preserved. This is why my client code is running into errors when trying to serialize the xml element back into a javabean (XmlBean object). It tries to find/match the original namespace of the <Box> element, but it is nowhere to be found. > 2) In addition to Muse removing the top element's namespace, it tries > to put in a default one instead. If my wsdl file contains the attribute xmlns="http://schemas.xmlsoap.org/wsdl/" > (which is defined in the samples), then Muse will take this namespace > and set it as the default in the <Box> element. So my client code complains of a namespace mismatch. (The namespace xmlns:tns="http://ws.apache.org/axis2" is also inserted either by Muse or Axis2, but it isn't causing problems at this moment.) So I think Muse should either properly preserve the xml operation results exactly as is, or put in the correct element namespaces and not override incorrectly. Muse does preserve notification outputs correctly, but it doesn't seem to do so for operations. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
