WodenHelloElement.java - Testing WSDL 2.0 Elements

This section provided a tutorial example on how to create a WSDLReader to parse a WSDL 2.0 document into WSDL element objects.

To see how the Element model works, I wrote this testing program to parse my WSDL 2.0 document, Hello_WSDL_20_SOAP.wsdl, into elements:

/* WodenHelloElement.java
 * Copyright (c) 2009 HerongYang.com. All Rights Reserved.
 */
import java.io.PrintStream;
import org.apache.woden.WSDLFactory;
import org.apache.woden.WSDLReader;
import org.apache.woden.wsdl20.Description;
import org.apache.woden.wsdl20.xml.DescriptionElement;
import org.apache.woden.wsdl20.xml.ServiceElement;
import org.apache.woden.wsdl20.xml.BindingElement;
import org.apache.woden.wsdl20.xml.InterfaceElement;
import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
import org.apache.woden.wsdl20.xml.TypesElement;
class WodenHelloElement {
   public static void main(String[] args) {
      PrintStream out = System.out;
      String wsdl = "file:///C:/herong/Hello_WSDL_20_SOAP.wsdl";

      try {

// Loading the WSDL 2.0 document
         WSDLFactory wFactory = WSDLFactory.newInstance();
         WSDLReader wReader = wFactory.newWSDLReader();
         wReader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
         Description wDescription = wReader.readWSDL(wsdl);

// Converting the document from Component model to Element model
         DescriptionElement eDescription = wDescription.toElement();

// Implementation class information
         out.println("Description object: "
            +eDescription.getClass().getName());

// Getting WSDL 2.0 document elements
         ServiceElement[] serviceList
            = eDescription.getServiceElements();
         out.println("First service name: "
            +serviceList[0].getName());

         BindingElement[] bindingList
            = eDescription.getBindingElements();
         out.println("First binding name: "
            +bindingList[0].getName());
         out.println("First binding type: "
            +bindingList[0].getType().toString());

         InterfaceElement[] interfaceList
            = eDescription.getInterfaceElements();
         out.println("First interface name: "
            +interfaceList[0].getName());

         InterfaceOperationElement[] operationList
            = interfaceList[0].getInterfaceOperationElements();
         out.println("First operation name: "
            +operationList[0].getName());
         out.println("First operation pattern: "
            +operationList[0].getPattern().toString());
         out.println("First operation style: "
            +operationList[0].getStyle()[0].toString());

         TypesElement eTypes = eDescription.getTypesElement();
         out.println("Types system: "+eTypes.getTypeSystem());

      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}

Result of this test program is listed below:

herong> javac -cp .;\local\axis2\lib\* WodenHelloElement.java

herong> java -cp .;\local\axis2\lib\* WodenHelloElement
WARNING: An illegal reflective access operation has occurred

Description object: org.apache.woden.internal.wsdl20.DescriptionImpl
First service name: {https://www.herongyang.com/Service/}helloService
First binding name: {https://www.herongyang.com/Service/}helloBinding
First binding type: http://www.w3.org/ns/wsdl/soap
First interface: {https://www.herongyang.com/Service/}helloInterface
First operation name: {https://www.herongyang.com/Service/}Hello
First operation pattern: http://www.w3.org/ns/wsdl/in-out
Types system: http://www.w3.org/2001/XMLSchema

Cool. The element model is also easy to use.

Table of Contents

 About This Book

 Introduction to WSDL 2.0

 WSDL 2.0 Document Structure and Syntax

 WSDL Version 2.0 Part 2: Adjuncts

 WSDL 2.0 Document Examples with SOAP Binding

 Using WSDL Document in Java Apache Axis2/Java for WSDL

Apache Woden for WSDL Documents in Java

 What Is Apache Woden - WSDL Parser API

 Java API for WSDL 2.0 Component Model

 WodenHelloComponent.java - Testing WSDL 2.0 Components

 Java API for WSDL 2.0 Element Model

WodenHelloElement.java - Testing WSDL 2.0 Elements

 Wsdl20Validator.java - WSDL 2.0 Validator

 WSDL 2.0-2 Adjuncts Not Supported by Woden API

 Convert WSDL 1.1 to 2.0 with Woden API

 SoapUI - Web Service Testing Tool

 PHP SOAP Extension for WSDL

 Perl SOAP::Lite for WSDL

 Introduction to WSDL 1.1

 WSDL 1.1 Document Structure and Syntax

 WSDL 1.1 Binding Extension for SOAP 1.1

 SoapUI as WSDL 1.1 Testing Tool

 WSDL 1.1 and SOAP 1.1 Examples - Document and RPC Styles

 PHP SOAP Extension for WSDL 1.1

 Perl SOAP::Lite for WSDL 1.1

 Apache Axis2/Java for WSDL 1.1

 Using WSDL2Java to Generate Web Service Stub Classes

 WSDL 1.1 Binding Extension for SOAP 1.2

 WSDL 1.1 and SOAP 1.2 Examples - Document and RPC Styles

 SOAP 1.2 Binding - PHP, Java and Perl Clients

 Python SOAP Client: Zeep

 WSDL Related Terminologies

 Archived Tutorials

 References

 Full Version in PDF/EPUB