【问题标题】:Failed to parse the WSDL无法解析 WSDL
【发布时间】:2017-10-10 08:48:14
【问题描述】:

我正在尝试使用以下教程从 wsdl 生成 src,但在 wsimport 时出现异常。

http://www.mkyong.com/webservices/jax-ws/jax-ws-wsgen-tool-example/

wsimport -keep -verbose http://localhost:7001/poc-war/ServerInfoService?wsdl

出现以下错误:

C:\Program Files\Java\jdk1.8.0_102\bin>wsimport -keep -verbose http://localhost:7001/poc-war/ServerInfoService?wsdl
parsing WSDL...


[ERROR] Server returned HTTP response code: 504 for URL: http://localhost:7001/poc-war/ServerInfoService?wsdl

Failed to read the WSDL document: http://localhost:7001/poc-war/ServerInfoService?wsdl, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>.


[ERROR] Could not find wsdl:service in the provided WSDL(s):

 At least one WSDL with at least one service definition needs to be provided.


        Failed to parse the WSDL.

ServerInfoService?wsdl

<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.mkyong.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="ServerInfoService" targetNamespace="http://ws.mkyong.com/">
    <wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://ws.mkyong.com/" targetNamespace="http://ws.mkyong.com/">
  <xsd:complexType name="getIpAddressResponse">
    <xsd:sequence>
      <xsd:element minOccurs="0" name="return" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="getIpAddress"/>
  <xsd:element name="getIpAddressResponse" type="ns0:getIpAddressResponse"/>
  <xsd:element name="getIpAddress" type="ns0:getIpAddress"/>
</xsd:schema>
    </wsdl:types>
    <wsdl:message name="getIpAddress">
        <wsdl:part element="tns:getIpAddress" name="parameters"/>
    </wsdl:message>
    <wsdl:message name="getIpAddressResponse">
        <wsdl:part element="tns:getIpAddressResponse" name="parameters"/>
    </wsdl:message>
    <wsdl:portType name="ServerInfo">
        <wsdl:operation name="getIpAddress">
            <wsdl:input message="tns:getIpAddress" name="getIpAddress"/>
            <wsdl:output message="tns:getIpAddressResponse" name="getIpAddressResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="ServerInfoServiceSoapBinding" type="tns:ServerInfo">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="getIpAddress">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="getIpAddress">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="getIpAddressResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="ServerInfoService">
        <wsdl:port binding="tns:ServerInfoServiceSoapBinding" name="ARMServicePortTypeImplPort">
            <soap:address location="http://10.19.9.92:7001/poc-war/ServerInfoService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

【问题讨论】:

  • 可以先从浏览器访问wsdl吗?似乎调用 url 由于超时而失败。可能是在您的环境中设置了未绕过本地主机的代理?
  • 是的,它可以从浏览器访问。网址:localhost:7001/poc-war/ServerInfoService?wsdl
  • 还有来自使用 wget 之类的命令提示符?为什么我这么说是因为 504 是明确的网关错误。会不会是从外部导入架构?

标签: java wsdl wsimport


【解决方案1】:

这是一个网络问题。您可以在浏览器中打开 wsdl 副本并将文本粘贴到新的 .wsdl 文件中,然后从硬盘驱动器 URL 与网络 URL 重新生成它。

我曾经有过网络安全性使我无法使用某些开发工具访问 WSDL 的情况,因此在本地保存副本可以工作。我承认这充其量只是一种解决方法,但如果没有更多信息,502 的故障排除并不容易。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-03
    • 1970-01-01
    • 1970-01-01
    • 2019-04-04
    • 1970-01-01
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多