Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a schema for WSDL with HTTP authentication and the maven-jaxb2-plugin

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>
like image 446
Swpno Avatar asked Feb 09 '17 12:02

Swpno


1 Answers

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.

like image 143
Tunaki Avatar answered Sep 24 '22 13:09

Tunaki