2

I want to use the cxf-maven-plugin to generate Java code from a WSDL per this doc: http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html

The service I am trying to reach is password protected. How do I specify a password? This doesn't seem to be documented.

 <plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>http://host/TheService.wsdl</wsdl>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>
awynne
  • 427
  • 5
  • 12
  • Andrew is right, there is no option for that, but you can try [my answer](http://stackoverflow.com/a/14044891/1071508). – Dawid Pytel Dec 26 '12 at 19:03

3 Answers3

3

You can use the basic auth scheme for URI like this :

<wsdl>http://username:password@host/TheService.wsdl</wsdl>

But if your wsdl reference xsd with a relative path, the username and password won't be used for loading those xsd... What you can do is to set an Authenticator globaly... What you need to do is to add the exec plugin to run a Class that will set the defaut Authenticator for the currently running jvm :

use http://mojo.codehaus.org/exec-maven-plugin/ and exec:java to run your class in the same jvm as the codegen plugin. The wsdl2java execution must happen after the exec:java. Your run class will set the Authenticator as explain here : http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-auth.html

Some day, we'll have a usefull -Ddefault.authenticatorClass=package.to.my.AuthenticatorImpl jvm arg...

avianey
  • 5,545
  • 3
  • 37
  • 60
0

Have you tried to include the user/password of the host within your user settings file (~/.m2/settings.xml)? I would try this and see what happens.

Ither
  • 2,527
  • 3
  • 27
  • 39
0

It seems there's no way to download password protected wsdl with this plugin, at least there are no corresponding fields in WsdlOption that you actually configure.

Instead, in CXF versions 2.3+ you can configure a wsdl from maven repository with <wsdlArtifact> and install the manually downloaded wsldfile

Community
  • 1
  • 1
  • Another workaround, also assuming that you're ok with manually downloading the wsdl to the project, is specifying local wsdl file in `` tag and remote path in `` – Andrew Yakovenko Jan 27 '11 at 16:30