0

I used cxf-codegen-plugin to generate client classes:

<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>

I found that policies attached in "webservices:ws-something:1.0-SNAPSHOT:wsdl" were not found in the generated classes. When send requests using the client:

<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>

, the server complains:

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 annotations are present in client classes, while Apache CXF annotations like "@Policies" and "@Policy" are missing.

Is that normal? What I should do to apply policies at the client side?

whz-pa
  • 25
  • 4

1 Answers1

0

Provide the wsdlLocation attribute to the jaxws:client. The policies are always pulled from the WSDL whenever possible.

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37