【问题标题】:How to parse a WSDL file to extract the contents of a particular node如何解析 WSDL 文件以提取特定节点的内容
【发布时间】:2013-02-12 16:41:30
【问题描述】:

这是我的 wsdl 文件的一部分:

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
- <s:element name="BinaryConversion">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="Binary" type="s:string" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="BinaryConversionResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="BinaryConversionResult" type="s:string" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="Qos">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="Availabilty_10" type="s:int" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="QosResponse">
  <s:complexType /> 
  </s:element>
- <s:element name="GetQosParameters">
  <s:complexType /> 
  </s:element>
- <s:element name="GetQosParametersResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="GetQosParametersResult" type="tns:QoSParameters" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="QoSParameters">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="Availability" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Accuracy" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Accessibility" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Latency" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Reliability" type="s:string" /> 
  </s:sequence>
  </s:complexType>
  </s:schema>
  </wsdl:types>

现在我想提取名称可用性、准确性、延迟等。我该怎么做。 我使用 Document Builder 进行解析,但我只能提取 wsdl:operations 而不是 wsdl:types

【问题讨论】:

    标签: java xml parsing wsdl wsdl2java


    【解决方案1】:

    这是一个很好的 Java/XML 教程(其中之一):

    向下滚动到他谈论XPath 的部分。这就是获取子节点(例如“QoSParameters”)及其中的所有内容(例如“可用性”、“准确性”等)所需的语法。

    【讨论】:

    • Tanq paul,但我使用了 NodeList elements = d.getElementsByTagName("s:complexTypes");它不工作,是我的语法错误,我能够提取服务名称,操作等,但不是 complexTypes
    猜你喜欢
    • 2020-09-30
    • 2013-03-15
    • 2022-06-17
    • 2013-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-26
    相关资源
    最近更新 更多