How to get complex types from a WSDL file?

I have the following wsdl file:

 <wsdl:types>
  <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http:..."/>
   <complexType name="BaseBean">
    <sequence/>
   </complexType>
   <complexType name="DateBean">
    <complexContent>
     <extension base="impl:BaseBean">
      <sequence>
       <element name="date" nillable="true" type="xsd:dateTime"/>
      </sequence>
     </extension>
    </complexContent>
   </complexType>
  </schema>
 </wsdl:types>

Using WSDL4J, I can get wsdl:typesnode:

WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
Definition definition = reader.readWSDL("file.wsdl");
Types types = definition.getTypes();

But I can’t figure out how to get complex typesinside types.

How can I get complex types programmatically? Where can I find an example on how to do this?

+3
source share
1 answer

Try to do:

Schema schema = null;
for (Object e : types.getExtensibilityElements()) {
    if (e instanceof Schema) {
        schema = (Schema)e;
        break;
    }
}
if (schema != null) {
    Element schemaElement = schema.getElement();
    // ...
}

At the moment, you really get an instance org.w3c.dom.Elementthat represents the schema.

0
source

Source: https://habr.com/ru/post/1759141/


All Articles