Ошибка при создании классов Java из WSDL - PullRequest
0 голосов
/ 28 октября 2019

У меня проблема с генерацией Java-классов из WSDL. Я использую Intelij. Wsdl написан на php. Я написал клиент на php, и он работает нормально. В Java у меня есть такие генераторы: wsimport, axis и axis 2, но без результата. Это ошибка на оси:

org.xml.sax.SAXException: Fatal Error: URI=myurl.wsdl Line=1: White spaces are required between publicId and systemId.
        at org.apache.axis.utils.XMLUtils$ParserErrorHandler.fatalError(XMLUtils.java:723)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1427)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanExternalID(XMLScanner.java:1039)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.scanDoctypeDecl(XMLDocumentScannerImpl.java:687)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:967)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:232)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
        at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
        at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
        at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
        at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
        at java.lang.Thread.run(Thread.java:662)

эта ошибка на оси 2:

[Fatal Error] Natgeo3.wsdl:1:50: White spaces are required between publicId and systemId.
log4j:WARN No appenders could be found for logger (org.apache.axis2.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL
    at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:180)
    at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:50)
    at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'https://nationalgeographic.ge/soap/Natgeo3.wsdl'.: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
    at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.readInTheWSDLFile(CodeGenerationEngine.java:312)
    at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:134)
    ... 2 more
Caused by: org.xml.sax.SAXParseException; systemId: myurl.wsdl; lineNumber: 1; columnNumber: 50; White spaces are required between publicId and systemId.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
    ... 7 more

, и это на wsimport:

[ERROR] DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.
  line 1 of myurl.wsdl

[ERROR] DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.

Failed to read the WSDL document: myurl.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.

А вот пример wsdl:

<?xml version="1.0"?>
<definitions name="Natgeo" targetNamespace="urn:Natgeo" xmlns:tns="urn:Natgeo"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">

  <types>
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Natgeo">
        <xsd:element name="getName" type="xsd:string" />
        <xsd:element name="HelloResponse" type="xsd:string" />
        <xsd:element name="doSQL" type="xsd:string" />
        <xsd:element name="SQLResponse" type="xsd:string" />
        <xsd:element name="tbcpay" type="xsd:string" />
        <xsd:element name="tbcpayResponse" type="xsd:string" />
        <xsd:element name="doSILKNET" type="xsd:string" />
        <xsd:element name="SILKNETResponse" type="xsd:string" />
        <xsd:element name="INDEX" type="xsd:string" />
        <xsd:element name="INDEXResponse" type="xsd:string" />
    </xsd:schema>           
  </types>

  <message name="dotbcpay">
    <part name="parameters" type="tns:tbcpay" />
  </message>
  <message name="dotbcpayResponse">
    <part name="parameters" type="tns:tbcpayResponse" />
  </message>

  <message name="doHello">
    <part name="parameters1" type="tns:getName" />
  </message>
  <message name="doHelloResponse">
    <part name="parameters2" type="tns:HelloResponse" />
  </message>

  <message name="doSQL">
    <part name="parameters3" type="tns:doSQL" />
  </message>
  <message name="doSQLResponse">
    <part name="parameters4" type="tns:SQLResponse" />
  </message>

  <message name="doSILKNET">
    <part name="parameters5" type="tns:doSILKNET" />
  </message>
  <message name="doSILKNETResponse">
    <part name="parameters6" type="tns:SILKNETResponse" />
  </message>  

  <message name="doINDEX">
    <part name="parameters7" type="tns:INDEX" />
  </message>
  <message name="doINDEXResponse">
    <part name="parameters8" type="tns:INDEXResponse" />
  </message>  

  <portType name="HelloPort">

    <operation name="doHello">
      <input message="tns:doHello" />
      <output message="tns:doHelloResponse" />
    </operation>
    <operation name="doSQL">
      <input message="tns:doSQL" />
      <output message="tns:doSQLResponse" />
    </operation>
    <operation name="dotbcpay">
      <input message="tns:dotbcpay" />
      <output message="tns:dotbcpayResponse" />
    </operation>
    <operation name="doSILKNET">
      <input message="tns:doSILKNET" />
      <output message="tns:doSILKNETResponse" />
    </operation>
    <operation name="doINDEX">
      <input message="tns:doINDEX" />
      <output message="tns:doINDEXResponse" />
    </operation>

  </portType>

  <binding name="HelloBinding" type="tns:HelloPort">

    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
      <operation name="doHello">
        <soap:operation soapAction="urn:HelloAction" />
        <input>
          <soap:body use="encoded" namespace="urn:Natgeo" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </input>

        <output>
          <soap:body use="encoded" namespace="urn:Natgeo" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </output>
      </operation>

      <operation name="doSQL">
        <soap:operation soapAction="urn:SQLAction" />
        <input>
          <soap:body use="encoded" namespace="urn:SQL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />       
        </input>

        <output>
          <soap:body use="encoded" namespace="urn:SQL" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />       
        </output>
      </operation>

      <operation name="dotbcpay">
        <soap:operation soapAction="urn:tbcpayAction" />
        <input>
          <soap:body use="encoded" namespace="urn:tbcpay" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </input>

        <output>
          <soap:body use="encoded" namespace="urn:tbcpay" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </output>
      </operation>

      <operation name="doSILKNET">
        <soap:operation soapAction="urn:SILKNETAction" />
        <input>
          <soap:body use="encoded" namespace="urn:SILKNET" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />      
        </input>

        <output>
          <soap:body use="encoded" namespace="urn:SILKNET" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />      
        </output>
      </operation>    

      <operation name="doINDEX">
        <soap:operation soapAction="urn:INDEXAction" />
        <input>
          <soap:body use="encoded" namespace="urn:INDEX" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </input>

        <output>
          <soap:body use="encoded" namespace="urn:INDEX" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />        
        </output>
      </operation>    

</binding>

  <service name="HelloService">
    <port name="HelloPort" binding="tns:HelloBinding">
        <soap:address location="wsdllocation" />
    </port>
  </service>

</definitions>
...