我使用“maven-jaxb22-plugin”生成类,以便我可以调用用 .Net 编写的 Web 服务。通常它工作正常,但这次,我只能使用客户端证书通过 HTTPS 访问 WSDL(无法通过 HTTP 访问)。
我能够让它与 SoapUI 一起工作。我将客户端证书添加到 JKS 密钥库中,并将其添加到 SoapUI 首选项中。然后我通过指定 URL 创建了一个新项目,如下所示:https://server.com/Service?wsdl https://server.com/Service?wsdl。 SoapUI 生成请求模板。我可以轻松查询网络服务并获得响应。这证明 WSDL 可用并且 Web 服务正在运行。
现在,在我的 pom 文件中,我正在使用这个插件:
<build>
<finalName>MyService</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb22-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<extension>true</extension>
<removeOldOutput>true</removeOldOutput>
<schemaLanguage>WSDL</schemaLanguage>
<verbose>true</verbose>
<schemaIncludes>
<includeSchema>https://server.com/Service?wsdl</includeSchema>
</schemaIncludes>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我如何告诉 Maven 我的客户端证书在哪里?
Thanks
你可以使用Maven 属性插件 http://mojo.codehaus.org/properties-maven-plugin/或使用 JVM 属性来提供信任存储位置。
In your POM 构建/插件部分,添加新的plugin条目,密钥库所在的位置你的KeyStore.jks对于这个例子:
..
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>javax.net.ssl.trustStore</name>
<value>${basedir}/src/test/jmeter/jmeterTrustedKeystore.jks</value>
</property>
<property>
<name>javax.net.ssl.keyStorePassword</name>
<value>changeit</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)