You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Rouble (JIRA)" <ji...@apache.org> on 2013/02/26 21:08:13 UTC

[jira] [Reopened] (CXF-4089) JavaToWS generating non-working WSDL

     [ https://issues.apache.org/jira/browse/CXF-4089?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rouble reopened CXF-4089:
-------------------------


Re-opening based on the findings of http://java.net/jira/browse/JAXB-880

I am looking for some help as to where the issue actually is. It seems like an interaction issue between CXF and JAXB.
                
> 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
>            Assignee: Daniel Kulp
>              Labels: javatows, wsdl
>             Fix For: Invalid
>
>         Attachments: cxfbug.tar.gz, FooWebService242.wsdl, FooWebService244.wsdl, README
>
>   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
For more information on JIRA, see: http://www.atlassian.com/software/jira