由cxf-codegen-plugin生成的客户端类:wsdl2java缺少WSDL中附加的策略

时间:2013-05-10 03:30:54

标签: jax-ws cxf ws-security wsdl2java

我使用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注释缺失。

这是正常的吗?我应该怎样做才能在客户端应用政策?

1 个答案:

答案 0 :(得分:0)

将wsdlLocation属性提供给jaxws:client。尽可能从WSDL中提取策略。