Daniel Szalay
Daniel Szalay

Reputation: 4101

Given a WSDL, how to retrieve the information about the available operations?

Environment NetBeans 6.9.1, GlassFish 3.1 + METRO 2.1

I want to make a JSF page that lists all available operations in a web service. I already have a File instance containing the WSDL file. Given these, how should I go on with listing only the available operations. What would be the best way?

Thanks in advance!

Upvotes: 1

Views: 989

Answers (1)

Kal
Kal

Reputation: 24910

Use wsdl4j

import java.util.Map;
import javax.wsdl.Definition;
import javax.wsdl.Types;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;

public class WSDLInspect {
       public static void main( String[] args ) throws Exception {
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLReader reader = factory.newWSDLReader();

         // pass the URL to the reader for parsing and get back a WSDL definiton
         Definition wsdlInstance
              = reader.readWSDL( null, "xxx" );

         // get a map of the five specific parts a WSDL file
         Types types = wsdlInstance.getTypes();
         Map messages = wsdlInstance.getMessages();
         Map portTypes = wsdlInstance.getPortTypes();
         Map bindings = wsdlInstance.getBindings();
         Map services = wsdlInstance.getServices();

         /** Do other stuff with information **/

       }
    }

Upvotes: 2

Related Questions