开发者

How to get complex types from 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"/>
   开发者_StackOverflow   </sequence>
     </extension>
    </complexContent>
   </complexType>
  </schema>
 </wsdl:types>

Using WSDL4J, I can get the wsdl:types node:

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

But I cannot figure out how to get the complex types inside the types.

How can I get the complex types programatically? Where can I find an example on how do do it?


Try doing:

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

At this point, you really only get an org.w3c.dom.Element instance that represents the schema.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜