I'm trying to port a SOAP consuming application to JAVA. I'm having issues making cxf-codegen-plugin to read the WSDL, which is from a third party and it actually works. I'm guessing that the issue is that the WSDL is not fully compliant with the standard and CXF can't complete the parsing.
Following for example the tutorial at http://www.littlebigextra.com/consume-secure-soap-web-service-spring-boot-application/, I can succesfully parse the following WSDLs https://osetesting.bizlinks.com.pe/ol-ti-itcpe/billService?wsdl and https://test.conose.pe/ol-ti-itcpe/billService.svc, but can't process https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl, which would be funny if I weren't stuck in this issue, since the last one is SUPPOSED to be the reference for the first two.
I have also tried the SpringBoot tutorial at https://spring.io/guides/gs/consuming-web-service/, it doesn't raise an error, but it doesn't create the classes as well
Here is my pom (taken from http://www.littlebigextra.com/consume-secure-soap-web-service-spring-boot-application/)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test.wsdl</groupId>
<artifactId>test-sunat-soap-ws</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<cxf.version>3.1.10</cxf.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<additionalJvmArgs>
-Djavax.xml.accessExternalDTD=all
-Djavax.xml.accessExternalSchema=all
</additionalJvmArgs>
<sourceRoot>${basedir}/src/main/generated</sourceRoot>
<wsdlOptions>
<wsdlOption>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-p</extraarg>
<extraarg>sunat.generated</extraarg>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
</extraargs>
<!--<wsdl>https://osetesting.bizlinks.com.pe/ol-ti-itcpe/billService?wsdl</wsdl>-->
<!--<wsdl>https://test.conose.pe/ol-ti-itcpe/billService.svc</wsdl>-->
<wsdl>https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/src/main/generated</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run mvn generate-sources, I can see that is calling the wsdl2java tool
wsdl2java -encoding UTF-8 -d C:\dev-tools\testbizlinksgetstatuscdr\src\main\generated -verbose -p sunat.generated -exsh true https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl
However, I get the following stacktrace
org.apache.cxf.tools.common.ToolException: java.io.IOException: Server returned HTTP response code: 503 for URL: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?ns1.wsdl
at org.apache.cxf.tools.validator.internal.Stax2DOM.getDocument(Stax2DOM.java:64)
at org.apache.cxf.tools.validator.internal.Stax2DOM.getDocument(Stax2DOM.java:47)
at org.apache.cxf.tools.validator.internal.WSDLRefValidator.getWSDLDocument(WSDLRefValidator.java:168)
at org.apache.cxf.tools.validator.internal.WSDLRefValidator.getWSDLDocuments(WSDLRefValidator.java:185)
at org.apache.cxf.tools.validator.internal.WSDLRefValidator.isValid(WSDLRefValidator.java:231)
at org.apache.cxf.tools.validator.internal.WSDL11Validator.isValid(WSDL11Validator.java:134)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.validate(JAXWSDefinitionBuilder.java:207)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:201)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:414)
at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:279)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:511)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:954)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?ns1.wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at java.net.URL.openStream(URL.java:1045)
at org.apache.cxf.tools.validator.internal.Stax2DOM.getDocument(Stax2DOM.java:59)
... 37 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.681 s
[INFO] Finished at: 2019-07-18T15:21:38-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.3.2:wsdl2java (generate-sources) on project test-bizlinks-getstatuscdr: Execution generate-sources of goal org.apache.c
xf:cxf-codegen-plugin:3.3.2:wsdl2java failed:
[ERROR] Summary: Failures: 14, Warnings: 0
[ERROR]
[ERROR] <<< ERROR!
[ERROR] null
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[29,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendSummary][output:sendSummaryResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[27,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendSummary][input:sendSummaryRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[25,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendSummary] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[23,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendPack][output:sendPackResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[21,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendPack][input:sendPackRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[19,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendPack] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[17,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendBill][output:sendBillResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[15,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendBill][input:sendBillRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[13,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendBill] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[11,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:getStatus][output:getStatusResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[9,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:getStatus][input:getStatusRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[7,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:getStatus] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[5,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService] not exist.
[ERROR]
[ERROR] -> [Help 1]
Edited: I included the whole error output, since I realized there were additional errors after the stacktrace
The line 503 for URL: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?ns1.wsdl is what makes me think that the WSDL is not fully compliant (because of the ?ns1.wsdl param, instead of just ?wsdl) However, if I try to access that link, I do get the same WSDL as if I used the original link, so I don't understand the 503 error at all.
When I run the code from the second tutorial, I get the following messages
[INFO] --- maven-jaxb2-plugin:0.12.3:generate (default) @ sunat-consuming-web-service ---
[INFO] Up-to-date check for source resources [[https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl, file:/C:/dev-tools/sunatconsumingwebservice/pom.xml]] and taret resource
s [[]].
[WARNING] The URI [https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl] seems to represent an absolute HTTP or HTTPS URL. Getting the last modification timestamp is only po
ssible if the URL is accessible and if the server returns the [Last-Modified] header correctly. This method is not reliable and is likely to fail. In this case the last modification time
stamp will be assumed to be unknown.
[ERROR] Could not retrieve the last modification timestamp for the URI [https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl] from the HTTP URL connection. The [Last-Modifie
d] header was probably not set correctly.
[WARNING] Last modification of the URI [https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl] is not known.
[INFO] Sources are not up-to-date, XJC will be executed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Cool, no error... but also no classes at all. When I use any of the other two URLs, the classes are generated at target/xjc/sunat.wsdl, showing exactly the same messages.
I tried using verbose, with mvn generate-sources -X, but apart of showing additional messages about the settings, no errors or more information of why the classes aren't generated appears.
How can I get either code to generate the classes for the WS?