我想使用 cxf-maven-plugin 根据此文档从 WSDL 生成 Java 代码:http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
我尝试访问的服务受密码保护。如何指定密码?这似乎没有记录。
<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>
您可以使用 URI 的基本身份验证方案,如下所示:
<wsdl>http://username:password@host/TheService.wsdl</wsdl>
但是,如果您的 wsdl 使用相对路径引用 xsd,则用户名和密码将不会用于加载这些 xsd...您可以做的是全局设置一个身份验证器...您需要做的是添加 exec插件来运行一个类,该类将为当前运行的 jvm 设置默认的身份验证器:
use http://mojo.codehaus.org/exec-maven-plugin/ http://mojo.codehaus.org/exec-maven-plugin/和 exec:java 在与 codegen 插件相同的 jvm 中运行您的类。 wsdl2java 执行必须在 exec:java 之后发生。您的运行类将设置身份验证器,如下所述:http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-auth.html http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-auth.html
有一天,我们将拥有一个有用的 -Default.authenticator_Class=package.to.my.Authenticator Impl jvm arg...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)