Hi Dan, Few questions... 1) If I don't wrap my result in a <EquipmentOperationResponse/> element, I can see that Muse does automatically add that wrapper. So if I do happen to add the wrapper myself, is Muse stripping mines out and putting another one on?
2) If I don't use the response element, and my wsdl is updated to define a response containing a sequence of multiple elements, how would those elements be returned in a single Element object and still be auto-wrapped properly in the response? Should the convention be to always return a single object? In this case, a sequence of only one object, although the object itself can be a composite. 3) I've also tested without using the response wrapper, but it is still addding the <Box xmlns:equ="http://cisco.com/musebox/cap/equip"> node right under the response node, above the <equ:Box> node. This inserted node is not in the hardcoded xml I used to create the response, so I'm not sure where it's coming from. Now, looking at my wsdl definition, I'm not sure what the correct xml should look like. I need to figure out if my xmlbean is the issue or not. 4) Specifying a serializer in muse.xml for each custom type (i.e. Box) is probably not ideal for us because our underlying system has a large set of custom objects that can be passed around. For now, we want to try to stick to passing the Element representation of our objects since we're using XmlBeans for the xml serialization. -----Original Message----- From: Daniel Jemiolo [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 21, 2006 3:01 PM To: [email protected] Subject: RE: changed capability result data Not sure why the prefix is being dropped from <Box/>, but I'm guessing it was the same code that added the Axis2 namespace (in the Axis2 engine). The response element is created by Muse (<EquipmentResponse/>), so you don't need to include that. Just return the actual return value and not the wrapper around it. Try this first to see if it solves the problem. If that works, I would also propose the following to make things a bit more efficient and separate the XML serialization from your capability logic: 1. Change your method signature and implementation to return a Box object: public Box equipmentOperation() { Box box = ... // do work, make box return box; } 2. Add the following to muse.xml (under the root element): <custom-serializer> <java-serializable-type>your.package.name.Box</java-serializable-type/> <java-serializer-class>your.package.name.BoxSerializer</java-serializabl e-class> </custom-serializer> 3. Add the following class to the code that wsdl2java generated for you: package your.package.name; import javax.xml.namespace.QName; import org.w3c.dom.Element; import org.apache.muse.core.serializer.Serializer; public class BoxSerializer implements Serializer { public Class getSerializableType() { return Box.class; } public Object fromXML(Element xml) { // use XmlBeans-generated classes here } public Element toXML(Object obj, QName qname) // qname will be box:Box { // use the XmlBeans-generated classes here } } Once you've finished the Serializer class, just recompile/rebuild and run the application again. On the client side, you can use the BoxSerializer to convert the response XML to a Box object. "Vinh Nguyen \(vinguye2\)" <[EMAIL PROTECTED]> wrote on 11/21/2006 05:11:44 PM: > Reposting again in plain text since Outlook is messing up the namespaces > in the code... > > > There seems to be a problem with the way Muse returns capability results > to the client. For example, my capability returns a custom type wrapped > in an Element. The xml contains proper namespaces and prefixes. But, > when my test client receives the Element, the xml format has been > changed. I'm using XmlBeans for the serialization, and I'm running into > problems on the client side. Am I doing something wrong? > > My wsdl is as follows: > <xsd:schema > elementFormDefault="qualified" > targetNamespace="http://cisco.com/musebox/cap/equip"> > <xsd:element name="EquipmentOperation" type="xsd:string" /> > <xsd:element name="EquipmentOperationResponse"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="Box" type="bx:BoxType"/> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > </xsd:schema> > > My capability code is as follows: > String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > + "<equ:EquipmentOperationResponse xmlns:equ=\"http://cisco.com/musebox/cap/equip\">" > + "<equ:Box>" > + "<box:name> xmlns:box=\"http://cisco.com/musebox/schemas/box\">EPR ID: MuseResource-2</box:name>" > + "</equ:Box>" > + "</equ:EquipmentOperationResponse>"; > Document xmlDoc = XmlUtils.createDocument(xml); > System.out.println("xmlDoc toString:\n" + > XmlUtils.toString(xmlDoc)); > return XmlUtils.getFirstElement(xmlDoc); > > My client code is: > Element body = XmlUtils.createElement(IEquipmentCapability.OP_QNAME, param1); > Element response = invoke(IEquipmentCapability.OP_URI, body); > System.out.println("response:\n" + XmlUtils.toString(response)); > > Here's a snippet of the server side output: > xmlDoc toString: > <?xml version="1.0" encoding="UTF-8"?> > <equ:EquipmentOperationResponse xmlns:equ="http://cisco.com/musebox/cap/equip"> > <equ:Box> > <box:name xmlns:box="http://cisco.com/musebox/schemas/box">EPR ID: MuseResource-2</box:name> > </equ:Box> > </equ:EquipmentOperationResponse> > > Here's a snippet of the client incoming trace results: > [CLIENT TRACE] SOAP envelope contents (incoming): > ... > <soapenv:Body> > <muse-op:EquipmentOperationResponse xmlns:muse-op="http://cisco.com/musebox/cap/equip" xmlns:tns="http://ws.apache.org/axis2"> > <Box xmlns:equ="http://cisco.com/musebox/cap/equip"> > <equ:Box> > <box:name xmlns:box="http://cisco.com/musebox/schemas/box">EPR ID: MuseResource-2</box:name> > </equ:Box> > </Box> > </muse-op:EquipmentOperationResponse> > </soapenv:Body> > </soapenv:Envelope> > > My client code outputs this result: > response: > <?xml version="1.0" encoding="UTF-8"?> > <muse-op:EquipmentOperationResponse > xmlns:muse-op="http://cisco.com/musebox/cap/equip" xmlns:tns="http://ws.apache.org/axis2"> > <Box xmlns:equ="http://cisco.com/musebox/cap/equip"> > <equ:Box> > <box:name xmlns:box="http://cisco.com/musebox/schemas/box">EPR ID: MuseResource-2</box:name> > </equ:Box> > </Box> > </muse-op:EquipmentOperationResponse> > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
