[ https://issues.apache.org/jira/browse/CXF-4089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203732#comment-13203732 ]
Daniel Kulp commented on CXF-4089: ---------------------------------- This is definitely a JAXB issue and not a CXF issue. If I remove the jaxb-impl and jaxb-xjc jars from the 2.4.2 CXF_HOME/lib dir and replace them with the jars from the latest CXF versions, then the generated WSDL has the same issue. If I completely remove those two jars and remove the call to wsdl2java (java2ws can use the JAXB built into the JDK) and run with both Java6 and Java7, Java6-u29 matches your 2.4.2 output and Java7u2 matches the later output which is not surprising as Java7 has the latest JAXB. This needs to be reduced to just a call to schemagen and likely filed with JAXB. I won't have time immediately to do that, but it definitely isn't a CXF issue. > JavaToWS generating non-working WSDL > ------------------------------------ > > Key: CXF-4089 > URL: https://issues.apache.org/jira/browse/CXF-4089 > Project: CXF > Issue Type: Bug > Affects Versions: 2.4.3, 2.4.4, 2.4.5, 2.4.6 > Environment: N/A > Reporter: Rouble > Labels: javatows, wsdl > Attachments: FooWebService242.wsdl, FooWebService244.wsdl, README, > cxfbug.tar.gz > > Original Estimate: 48h > Remaining Estimate: 48h > > 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: > <code> > @XmlRootElement(name = "Widget") > @XmlAccessorType(XmlAccessType.PROPERTY) > @XmlType(name = "Widget") > public class Widget { > private FOO foo; > private Bar bar; > > public FOO getFOO() { > return foo; > } > public void setFOO(FOO foo) { > this.foo = foo; > } > public Bar getBar() { > return bar; > } > public void setBar(Bar bar) { > this.bar = bar; > } > } > </code> > The WSDL generated by JavaToWS looks like this: > <wsdl> > <xs:complexType name="Widget"> > <xs:sequence> > <xs:element minOccurs="0" name="bar" type="tns:Bar"/> > <xs:element minOccurs="0" ref="tns:FOO"/> > </xs:sequence> > </xs:complexType> > </wsdl> > 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: > <code> > @XmlAccessorType(XmlAccessType.FIELD) > @XmlType(name = "Widget", propOrder = { "bar", "foo" }) > public class Widget { > protected Bar bar; > @XmlElement(name = "FOO", namespace = "http://example.com/") > protected FOO foo; > <SNIP> > } > </code> > 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="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Body> > <ns2:getWidgetResponse xmlns:ns2="http://example.com/"> > <return> > <bar> > <intBar>7</intBar> > </bar> > <FOO> > <fooInt>99</fooInt> > </FOO> > </return> > </ns2:getWidgetResponse> > </soap:Body> > </soap:Envelope> > And CXF throws the exception: > org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging > WARNING: Interceptor for > {http://example.com/}FooWebService#{http://example.com/}getWidget has thrown > exception, unwinding now > org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element > (uri:"", local:"FOO"). Expected elements are > <{http://example.com/}FOO>,<{}bar> > The CXF client is expecting FOO to be in the namespace http://example.com, > 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira