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-serializable-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]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to