【问题标题】:Given a WSDL, how to retrieve the information about the available operations?给定一个 WSDL,如何检索有关可用操作的信息?
【发布时间】:2023-03-16 09:27:02
【问题描述】:

环境 NetBeans 6.9.1、GlassFish 3.1 + METRO 2.1

我想创建一个 JSF 页面,列出 Web 服务中的所有可用操作。我已经有一个包含 WSDL 文件的 File 实例。鉴于这些,我应该如何继续仅列出可用的操作。最好的方法是什么?

提前致谢!

【问题讨论】:

    标签: java web-services jsf wsdl jax-ws


    【解决方案1】:

    使用 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 **/
    
           }
        }
    

    【讨论】:

    • 但是如果我想检索每个操作的输入参数,我该怎么做呢?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 2017-11-08
    • 2013-07-18
    • 2010-11-20
    相关资源
    最近更新 更多