0

我使用 cxf-codegen-plugin 生成客户端类:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.7.4</version>
    <executions>
        <execution>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdlArtifact>
                            <groupId>webservices</groupId>
                            <artifactId>ws-dosomething</artifactId>
                            <version>1.0-SNAPSHOT</version>
                        </wsdlArtifact>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

我发现在生成的类中找不到附加在“webservices:ws-something:1.0-SNAPSHOT:wsdl”中的策略。使用客户端发送请求时:

<cxf:bus>
    <cxf:features>
        <p:policies />
    </cxf:features>
</cxf:bus>

<jaxws:client id="DoSomethingService" address="http://localhost/cxf/services/dosomething" serviceClass="webservices.dosomething.DoSomethingService">
    <jaxws:properties>
        <entry key="ws-security.signature.properties" value="crypto.properties" />
        <entry key="ws-security.callback-handler" value="webservices.dosomething.WSPasswordProvider" />
    </jaxws:properties>
</jaxws:client>

,服务器抱怨:

org.apache.cxf.interceptor.Fault: These policy alternatives can not be satisfied: 
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}AsymmetricBinding: Received Timestamp does not match the requirements
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}X509Token: The received token does not match the token inclusion requirement
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}X509Token
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}InitiatorToken
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}RecipientToken
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}IncludeTimestamp: Received Timestamp does not match the requirements
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts: {http://schemas.xmlsoap.org/soap/envelope/}Body not SIGNED

客户端类中存在 JAX-WS 注释,而缺少诸如“@Policies”和“@Policy”之类的 Apache CXF 注释。

这正常吗?我应该怎么做才能在客户端应用策略?

4

1 回答 1

0

向 jaxws:client 提供 wsdlLocation 属性。策略总是尽可能从 WSDL 中提取。

于 2013-05-10T14:08:31.487 回答