9

I want to use jaxb2 plugin to generate a WSDL accessible from a secure URL (basic authentication with user id and password).

Where should I specify the credentials to generate the schema? Without providing them, I get one 401 error during schema generation.

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.13.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaLanguage>WSDL</schemaLanguage>
        <generatePackage>hello.wsdl</generatePackage>
        <schemas>
            <schema>
                <url>http://www.webservicex.com/stockquote.asmx?WSDL</url>
            </schema>
        </schemas>
    </configuration>
</plugin>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Swpno
  • 173
  • 1
  • 13

1 Answers1

5

HTTP authentication to download schemas is currently not supported, and a pull request to add it was declined, so it won't be implemented. This is because it is always preferable to download the WSDL and work on it locally, rather than downloading it during each build:

  • It makes the build highly dependant on the availability of the WSDL, something which may not be guaranteed and can end up failing your build for no reasons;
  • The build is no longer repeatable, which is contrary to what Maven is striving for, since you do not necessarily control how and when the remote WSDL is updated.

There is a somewhat hacky way to do this with Apache CXF Codegen Plugin instead, but I really wouldn't recommend it.

Community
  • 1
  • 1
Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • 1
    Understood. But even with a local copy, 0.14.0 tries to download the referenced schema from import schemaLocation and runs into a 401 here. How do you stop it from fetching the schema? – lilalinux Mar 10 '20 at 08:22
  • Never mind, I downloaded the import manually and changed the wsdl to reference it via schemaLocation="./foobar.xsd" – lilalinux Mar 10 '20 at 08:36