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

11,131

Looks like the behavior of the wsimport command is sensitive case. This answer mentions something similar.

The client was generate with (wsimport bundle with Oracle JDK version 1.8.0_202-b08):

wsimport -Xnocompile -extension -clientjar my.jar -d . -generateJWS https://core4.gatewayedi.com/V1/CAQHCoreIV/caqhcoreV4.svc?wsdl

The principal difference is the use of sensitive case in the URL. The URL https://core4.gatewayedi.com/V1/CAQHCoreIV/caqhcoreV4.svc?wsdl matches with the location entry in the WSDL file.

Share:
11,131
user650585
Author by

user650585

Updated on June 04, 2022

Comments

  • user650585
    user650585 almost 2 years

    I'm getting

    DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true
    line 1 of https://core4.gatewayedi.com/v1/caqhcoreiv/caqhcorev4.svc?wsdl

    error when using wsimport to generate java classes off of a wsdl file.

    Is there any workaround or solution to this issue, specifically when using wsimport?

    Following is the command I used as well as the complete response I got from wsimport:

    wsimport" -Xnocompile -extension -clientjar my.jar -d . -generateJWS https://core4.gatewayedi.com/v1/caqhcoreiv/caqhcorev4.svc?wsdl   
    

    parsing WSDL...

    [ERROR] DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true. line 1 of https://core4.gatewayedi.com/v1/caqhcoreiv/caqhcorev4.svc?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: https://core4.gatewayedi.com/v1/caqhcoreiv/caqhcorev4.svc?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.

    Downloading the WSDL and associated metadata

        Exception in thread "main" java.lang.IllegalStateException: DOMStreamReader: Calling next() at END_DOCUMENT
        at com.sun.xml.internal.ws.streaming.DOMStreamReader._next(DOMStreamReader.java:764)
        at com.sun.xml.internal.ws.streaming.DOMStreamReader.next(DOMStreamReader.java:737)
        at com.sun.xml.internal.ws.util.xml.XMLStreamReaderToXMLStreamWriter.bridge(XMLStreamReaderToXMLStreamWriter.java:92)
        at com.sun.tools.internal.ws.util.WSDLFetcher.fetchFile(WSDLFetcher.java:121)
        at com.sun.tools.internal.ws.util.WSDLFetcher.fetchWsdls(WSDLFetcher.java:86)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:437)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:190)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:168)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
        at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)
    
    • JuanMoreno
      JuanMoreno about 4 years
      Looks like your wsdl file has an invalid format, If you look the reference in the w3c w3.org/TR/wsdl.html#_wsdl, the wsdl file doesn't have the DOCTYPE entry. The first line would be <?xml version="1.0" encoding="UTF-8"?>
    • user650585
      user650585 about 4 years
      @SHoko No I don't think it does. Here is the WSDL file: core4.gatewayedi.com/v1/caqhcoreiv/caqhcorev4.svc?wsdl
    • JuanMoreno
      JuanMoreno about 4 years
      When I process the wsdl with the wsimport bundle with java version 1.8.0_202-b08, I get a different error, related to [ERROR] duplicate "message" entity: "RealTimeRequestMessage"
    • user650585
      user650585 about 4 years
      @SHoko Honestly it changes from time to time. I have also seen the error you mentioned. So do you know why wsimport returns such error?
    • JuanMoreno
      JuanMoreno about 4 years
      It's very weird, It's related to this stackoverflow.com/questions/52123489/…. In my case I generate your client using this line: wsimport -Xnocompile -extension -clientjar my.jar -d . -generateJWS https://core4.gatewayedi.com/V1/CAQHCoreIV/caqhcoreV4.svc?ws‌​dl The principal difference is the use of sensitive case in the URL.
    • user650585
      user650585 about 4 years
      @SHoko so it is all about the URL case. Thanks a lot.