cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pranab Mehta (Created) (JIRA)" <>
Subject [jira] [Created] (CXF-4089) JavaToWS generating non-working WSDL
Date Tue, 07 Feb 2012 22:12:59 GMT
JavaToWS generating non-working WSDL

                 Key: CXF-4089
             Project: CXF
          Issue Type: Bug
    Affects Versions: 2.4.6, 2.4.5, 2.4.4, 2.4.3
         Environment: N/A
            Reporter: Pranab Mehta

I use JavaToWS to generate the WSDL on my development box. After migrating to 2.4.3 (from
2.4.1) I noticed that the WSDL being generated is slightly different (uses references). And
any clients generated using wsdl2java, on that WSDL do not work. This issue is easily reproducible.

The data object in question is, lets say, a Widget, and the SOAP API call is getWidget().
Here is what Widget looks like:
@XmlRootElement(name = "Widget")
@XmlType(name = "Widget")
public class Widget {
    private FOO foo;
    private Bar bar;
    public FOO getFOO() {
        return foo;
    public void setFOO(FOO foo) { = foo;
    public Bar getBar() {
        return bar;
    public void setBar(Bar bar) { = bar;

The WSDL generated by JavaToWS looks like this:
<xs:complexType name="Widget">
        <xs:element minOccurs="0" name="bar" type="tns:Bar"/>
        <xs:element minOccurs="0" ref="tns:FOO"/>

Notice how bar is explicitly listed inline, but FOO is referred to via a reference. Both bar
and FOO have the exact same annotations. In CXF 2.4.1, both of these elements would be explicitly
listed inline.

And the generated code using wsdl2java looks like this:
    @XmlType(name = "Widget", propOrder = { "bar", "foo" })
    public class Widget {
        protected Bar bar;
        @XmlElement(name = "FOO", namespace = "")
        protected FOO foo;

Notice, that FOO is explicitly marked to be in a namespace in the generated code, and bar
is in no explicit namespace.

Now, when we call the getWidget() on the web service, we get back:
<soap:Envelope xmlns:soap="">
        <ns2:getWidgetResponse xmlns:ns2="">

And CXF throws the exception:
org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {}FooWebService#{}getWidget
has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"", local:"FOO").
Expected elements are <{}FOO>,<{}bar>

The CXF client is expecting FOO to be in the namespace, but JAXB does not
namespace elements. Hence the exception. bar is unmarshalled just fine. Now this worked fine
in when we used JavaToWS in 2.4.1 and is broke now.

Note I have done some more testing, and 2.4.2 is fine, but 2.4.3 onwards is broke. I switched
out the CXF 2.4.3 to use CXF 2.4.1's JAXB jars, and the problem still exists.

The bug is easily reproducible - but I can add sample code if required.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message