Hello, I'm using jdk 1.5_11, CXF 2.1.2, jaxb 2.1.7, and jax-ws
2.1(geronomo-jaxws_2.1_spec-1.0.jar). I'm using a wsdl first approach. I'm
running cxf's wsdl2java against a single wsdl document(no addtl jaxb binding
annotations present) with several schemas defined within. I've tried to
summarize the wsdl/schema here:

<definitions
    name="MyService"
    targetNamespace="http://namespaces.my.stuff";
    xmlns="http://schemas.xmlsoap.org/wsdl/";
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/";
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    xmlns:xsdQueryRequestContainer="http://namespaces.my.stuff/QueryBatch";
    xmlns:xsdDerivedQuery1="http://namespaces.my.stuff/DerivedQuery1";
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"; 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    <types>
         <xsd:schema
            targetNamespace="http://namespaces.my.stuff/QueryBatch";>
            
            <xsd:complexType name="commandType">
                .....                
            </xsd:complexType>
            
            <xsd:element name="QueryBatchCommands">
                <xsd:complexType>
                    <xsd:choice maxOccurs="unbounded" minOccurs="1">
                         <xsd:element
                            name="command"
                            type="xsdQueryRequestContainer:commandType"/>
                     </xsd:choice>
                </xsd:complexType>
            </xsd:element>
      </xsd:schema>

       <xsd:schema
            targetNamespace="http://namespaces.my.stuff/DerivedQuery1";
            xmlns:xsdQueryBatch="http://namespaces.my.stuff/QueryBatch";>
            <xsd:import namespace="http://namespaces.my.stuff/QueryBatch"/>
            
            <xsd:complexType name="commandType">
                <xsd:complexContent>
                    <xsd:extension base="xsdQueryBatch:commandType">
                          ......
                    </xsd:extension>
                </xsd:complexContent>
            </xsd:complexType>
            <xsd:element name="command">
                <xsd:complexType>
                    <xsd:complexContent>
                        <xsd:extension base="xsdDerivedQuery1:commandType">
                        </xsd:extension>
                    </xsd:complexContent>
                </xsd:complexType>
            </xsd:element>
           
        </xsd:schema>

</definitions>


After running cxf wsdl2java I have the following generated
classes(abbreviated for display):

package stuff.my.namespaces.querybatch;
/**
 * <p>Java class for commandType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained
within this class.
 * 
 * <pre>
 * &lt;complexType name="commandType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType";>
           .....
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "commandType", propOrder = {
    "...."
})
@XmlSeeAlso({
    stuff.my.namespaces.derivedquery1.CommandType.class
})
public class CommandType {
.....
}




package stuff.my.namespaces.derivedquery1;
/**
 * <p>Java class for commandType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained
within this class.
 * 
 * <pre>
 * &lt;complexType name="commandType">
 *   &lt;complexContent>
 *     &lt;extension
base="{http://namespaces.my.stuff/QueryBatch}commandType";>
        .......
 *     &lt;/extension>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "commandType", propOrder = {
    "...."
})
@XmlSeeAlso({
    stuff.my.namespaces.derivedquery1.Command.class
})
public class CommandType
    extends stuff.my.namespaces.querybatch.CommandType
{
    .....
}




package stuff.my.namespaces.derivedquery1;
/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained
within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;extension
base="{http://namespaces.my.stuff/DerivedQuery1}commandType";>
       ......
 *     &lt;/extension>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "...."
})
@XmlRootElement(name = "command")
public class Command
    extends CommandType
{
   .....
}




package stuff.my.namespaces.querybatch;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained
within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType";>
 *       &lt;choice maxOccurs="unbounded">
 *         &lt;element name="command"
type="{http://namespaces.my.stuff/QueryBatch}commandType"/>
 *       &lt;/choice>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "command"
})
@XmlRootElement(name = "QueryBatchCommands")
public class QueryBatchCommands {
    protected List<CommandType> command;

    /**
     * Gets the value of the command property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the command
property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getCommand().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * [EMAIL PROTECTED] CommandType }
     * 
     * 
     */
    public List<CommandType> getCommand() {
        if (command == null) {
            command = new ArrayList<CommandType>();
        }
        return this.command;
    }

}




The client tries to do following:

stuff.my.namespaces.querybatch.QueryBatchCommands qbc = new
stuff.my.namespaces.querybatch.QueryBatchCommands();
qbc.getCommand().add(new stuff.my.namespaces.derivedquery1.Command());
service.serviceMethod(qbc);

When doing the service invocation method, the runtime throws:

Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: Instance of
"stuff.my.namespaces.dereivedquery1.Command" is substituting
"stuff.my.namespaces.querybatch.CommandType", but
"stuff.my.namespaces.derivedquery1.Command" is bound to an anonymous type.
        at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:174)
        at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:131)
        at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:104)
        at
org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
Caused by: javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.SAXException2: Instance of
"stuff.my.namespaces.derivedquery1.Command" is substituting
"stuff.my.namespaces.querybatch.CommandType", but
"stuff.my.namespaces.derivedquery1.Command" is bound to an anonymous type.]
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:331)
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257)
        at
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
        at
org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:379)
        at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:155)
        ... 33 more
Caused by: com.sun.istack.SAXException2: Instance of
"stuff.my.namespaces.derivedquery1.Command" is substituting
"stuff.my.namespaces.querybatch.CommandType", but
"stuff.my.namespaces.derivedquery1.Command" is bound to an anonymous type.
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:244)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:659)
        at
com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:65)
        at
com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
        at
com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:152)
        at
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:322)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:151)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312)
        at
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:71)
        at
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
        at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
        ... 37 more

I read through the NFL/Groovy
http://www.nabble.com/org.apache.cxf.interceptor.Fault%3A-Marshalling-Error-with-NFL-GroovyWS-td14102934.html
 
thread , and that seemed to have same exception message but from a different
type of schema usage..the research I've done so far seems to say
'@XmlSeeAlso' should enable polymorphic elements to work with jaxb.


-- 
View this message in context: 
http://www.nabble.com/client-side-JAXB-marshalling-error%28instance-of-xxx-is-substituting-yyy-but-xxx-is-bound-to-an-anonymous-type%29-on-polymorphic-element-tp20193622p20193622.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to