Search code examples
javasoapwsdlwsimport

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


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)

Solution

  • 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.