Search code examples
javawsdlwsimport

Failed to parse the WSDL


I am trying to generate src from wsdl using following tutorial but getting exception while wsimport.

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

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

Getting following error :

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>

Solution

  • This is a networking issue. You could open the wsdl in your browser copy and paste the text into a new .wsdl file and regenerate it from the hard drive URL vs a network URL.

    I have had times where network security has made it impossible for me to reach WSDL's using some development tools so keeping a copy locally can work. I admit it is a work around at best but 502 is not easy to troubleshoot without a lot more information.