Ok this is how I've made it work:
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import org.w3c.dom.Element;
public class SchemaExtensible
{
@XmlAnyElement(lax=true)
private List<Element> otherElements;
@XmlAnyAttribute
private Map<QName,Object> otherAttributes;
}
It's not ideal because now I have to extend this class for every response class that I want to be extensible (and in some cases this stops me from extending from a request class instead). If these 2 method & field level annotations could be enhanced to allow them to be added at the class level then they could simply be saying "add the appropriate tags to the schema and just throw away the data if encountered" which would be sweet.
Any way the schema fragment ends up looking like this:
<xs:complexType name="SchemaExtensible">
<xs:sequence>
<xs:any processContents="lax" namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="skip"/>
</xs:complexType>
For me, allowing this extensibility for response objects only is preferable to web service versioning as it allows you to evolve the schema bit by bit, if you so desire, without the headache of managing many different versions, and without the worry that any existing clients will break if you add a single new attribute or element to a response object.