Question

Using CXF 2.3.1.

Generated Java from WSDLs using JAXB.

Using

<jaxws:properties>
    <entry key="schema-validation-enabled" value="true" />
</jaxws:properties>

in the client configuration.

My test creates an object that fails this particular requirement of the WSDL:

<xsd:simpleType name="UUID.Content">
    <xsd:annotation>
        <xsd:documentation xml:lang="EN">
            Universally Unique Identifier
            </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:token">
        <xsd:length value="36" />
        <xsd:pattern
            value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" />
    </xsd:restriction>
</xsd:simpleType>

However, the message is marshalled and makes it all the way through the outgoing interceptor chain.

The WSDL is one-way: input-only.

wsdlLocation is specified in an annotation in the Impls.

Interestingly, incoming messages that fail validation of this same constraint are blocked by the interceptor chain during unmarshalling.

I'm testing on WebLogic. I could also test on WebSphere is needed.

Other XSD validation failures (such as a missing required element) are being caught by the outgoing marshaller.

The reason that we upgraded to CXF 2.3.1 from 2.2.6 was that we were seeing similar issues on the inbound messages. In 2.3.1, complete XSD validation occurs for inbound messages but not for outbound ones.

Here is the bug in CXF:

https://issues.apache.org/jira/browse/CXF-3233

We worked around this by using org.springframework.xml.validation.XmlValidator to validate before sending the message to the CXF interceptor chain. I'm hoping for fixes that use the CXF interceptor chain. However, I suspect that this is a bug in CXF.

Was it helpful?

Solution

I've had similar problems (CXF 2.2.7) and was able to solve it by adding the serviceName and endpointName attributes to my <jaxws:client> bean definition. check out the section "Configuring a Spring Client (Option 1)" here: https://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html for more information on the attributes.

Note: I also have the wsdlLocation attribute defined as well. This is likely necessary for CXF to find the XSDs used by the service.

Here's an example of what I have:

<jaxws:client id="client"
              serviceClass="com.example.ServiceInterface"
              address="http://example.com/endpoint"
              wsdlLocation="WEB-INF/wsdl/SampleWSDLFile.wsdl"
              serviceName="s:SampleService"
              endpointName="s:SampleServicePort"
              xmlns:s="http://www.example.com/some/namesapce">
...
</jaxws:client>

I also noticed when I had this problem the whole schema was printed to my log file by the org.apache.cxf.wsdl.EndpointReferenceUtils class every time the client was invoked. This behavior went away when I setup my client bean like the one above. I wonder if you're seeing something like that too...

Another detail I should mention is that I had a lot of unexpected behavior from CXF when I didn't use all the CXF-provided libraries outlined in the WHICH_JARS file. I would also try adding them to the build so they override any server or Java provided libraries. You can always remove them later if they aren't necessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top