简体   繁体   中英

Apache CXF parse WSDL Schema xsd:any type

I am trying to find good and most generic solution for soap web services' problem. The problem I need to solve is to replace proxies which Apache Axis generate using given WSDL file with the proxies that Apache CXF genereta using wsdl2java command. However, when I generate proxies with CXF and opened the classes in IDE I realised that I have:

@XmlAnyElement(lax = true)
    protected List<Object> any;

element as a Class field. This was strange. I looked at the pure wsdl and in one of the complextype properties there is xsd:any element. I have been searching for a long time what is the problem and for the best solution to solve it. I found this . It seems that apache CXF runtime cannot determine the actual data type of the element. So I need to parse it manually with DOM parser.

Apache Axis generate the following:

private org.apache.axis.message.MessageElement[] _any;

The tag:

<any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded" />

My question is: What is the best way to solve this problem? Do I really need DOM parser to ? Is there something that i miss ? Thank you.

<xsd:any> is used to allow in the schema any element. See this link

The element enables us to extend the XML document with elements not specified by the schema.

So mapping of CXF is correct. The JAXB annotation @XmlAnyElement(lax = true) means that for that field if contains an element annotated with @XmlRootElement or @XmlElementDecl then an instance of the corresponding class will be used to populate the field if not the element will be set as an instance of org.w3c.dom.Element .

See an example here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM