I have a WSDL that uses the xsd:any
element in the return type for one of the methods, for example:
<xs:element name="Method_XMLResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="1" name="Method_XMLResult"> <xs:complexType mixed="true"> <xs:sequence> <xs:any/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element>
When I run WSDL using the wsimport
tool, I get a generated class that has this xs:any
field, displayed as a list of objects:
public static class MethodXMLResult { @XmlMixed @XmlAnyElement(lax = true) protected List<Object> content; }
When I call the service using the generated code, I get instances of org.w3c.dom.Node
in the content
list ( com.sun.org.apache.xerces.internal.dom.ElementNSImpl
, to be precise) that I will need to parse. However, I was provided with a separate external schema document for the returned objects - and I'm trying to somehow pass it to wsimport
so that it also generates classes for them.
I am trying to accomplish this through a JAX-WS / JAXB configuration file as follows:
<jaxws:bindings xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:a="http://www.w3.org/2001/XMLSchema" wsdlLocation="wsdlLocation.wsdl"> <jaxws:bindings node="wsdl:definitions"> <jaxws:bindings node="wsdl:types" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"> <jaxws:bindings node="//s:schema[@targetNamespace='wsNamespace']"> <jaxb:bindings node="//s:element[@name='Method_XMLResponse']//s:any"> ... </jaxb:bindings> </jaxws:bindings> </jaxws:bindings> </jaxws:bindings> </jaxws:bindings>
It seems that wsimport
is choosing the right place to configure (it gave me a lot of errors with the correct line number in the WSDL), but I can’t figure out how to populate the <jaxb:bindings>
element to make wsimport
generate classes from an external schema. Is it possible? Any help would be greatly appreciated.
source share