【发布时间】:2014-10-29 20:06:46
【问题描述】:
我是不受我控制的 SOAP 服务的客户端(在 .NET 中实现)。该服务提供一个 WSDL。我使用 Apache CXF 从 WSDL 生成 java 客户端(具体来说,我使用 Maven 的 cxf-codegen-plugin,它在后台使用 wsdl2java)。
但是,当我实例化生成的服务类时,会记录以下警告:
Sep 04, 2014 5:18:00 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}TransportBinding" was evaluated as "UNKNOWN".
Sep 04, 2014 5:18:00 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
但是客户端可以正常工作——我使用该服务没有任何问题。但是,我对这些错误感到困惑。
错误是关于 WSDL 中的这个安全策略,我认为它说它无法理解:
<wsp:Policy wsu:Id="soap11_policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
但据我所知,这是一项完全普通的政策,没有什么不寻常的地方。应该明白了吧?如何解决此警告?
为了记录,这里是调用 wsdl2java 的方式(摘自 pom.xml)。
-exsh true arg 和 cxf-rt-bindings-soap 依赖项是因为 WSDL 在其参数中使用了一些隐式的 soap 标头,我需要它以便将它们正确包含在生成的服务类方法中。
我添加了 cxf-rt-ws-security 和 cxf-rt-ws-policy 依赖项以尝试修复此警告,认为可能未包含安全和策略信息。然而,这并没有解决任何问题(虽然也没有破坏任何东西)。
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>rh-soap-client-ssi</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>https://example.org/ssi?wsdl</wsdl>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-client</extraarg>
<extraarg>-mark-generated</extraarg>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
<extraarg>-autoNameResolution</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
</plugin>
【问题讨论】:
标签: wsdl cxf jax-ws soap-client wsdl2java