解析 WSDL 失败

Failed to parse the WSDL

我正在尝试使用以下教程从 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,将文本复制并粘贴到新的 .wsdl 文件中,然后从硬盘 URL 与网络 URL.

重新生成它

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