将 WSDL 文件导入 SoapUI 时出错

Getting error when importing WSDL file to SoapUI

提问人:Het Patel 提问时间:11/14/2023 更新时间:11/14/2023 访问量:22

问:

我正在使用 localhost URL 导入 WSDL。我也尝试直接导入 WSDL 文件,但遇到了同样的错误。

错误: WSDLException(位于 /definitions):faultCode=INVALID_WSDL:预期元素“{http://schemas.xmlsoap.org/wsdl/}definitions”。

WSDL 代码:

<definitions name="WeatherService"
  targetNamespace="http://localhost:8000/weather"
  xmlns:tns="http://localhost:8000/weather"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <types>
    <xsd:schema>
      <xsd:element name="GetWeatherRequest">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="location" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="GetWeatherResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="temperature" type="xsd:string"/>
            <xsd:element name="description" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </types>

  <message name="GetWeatherRequestMessage">
    <part name="request" element="tns:GetWeatherRequest"/>
  </message>
  <message name="GetWeatherResponseMessage">
    <part name="response" element="tns:GetWeatherResponse"/>
  </message>

  <portType name="WeatherPortType">
    <operation name="GetWeather">
      <input message="tns:GetWeatherRequestMessage"/>
      <output message="tns:GetWeatherResponseMessage"/>
    </operation>
  </portType>

  <binding name="WeatherBinding" type="tns:WeatherPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="GetWeather">
      <soap:operation soapAction="http://localhost:8000/weather/GetWeather"/>
      <input>
        <soap:body use="literal" namespace="http://localhost:8000/weather"/>
      </input>
      <output>
        <soap:body use="literal" namespace="http://localhost:8000/weather"/>
      </output>
    </operation>
  </binding>

  <service name="WeatherService">
    <port name="WeatherPort" binding="tns:WeatherBinding">
      <soap:address location="http://localhost:8000/weather"/>
    </port>
  </service>

</definitions>
XML SOAP WSDL SOAPUI

评论

0赞 jdweng 11/14/2023
我认为第二行是错误的。它是默认命名空间,应该是xmlns="http://localhost:8000/weather"

答: 暂无答案