Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4089

JavaToWS generating non-working WSDL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 2.4.3, 2.5, 2.4.4, 2.4.5, 2.4.6, 2.6, 2.7.1, 2.7.2, 2.7.3
    • Invalid
    • None
    • N/A

    • Novice

    Description

      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.

      Attachments

        1. cxfbug.tar.gz
          2 kB
          Rouble
        2. README
          1 kB
          Rouble
        3. FooWebService244.wsdl
          3 kB
          Rouble
        4. FooWebService242.wsdl
          3 kB
          Rouble

        Activity

          People

            dkulp Daniel Kulp
            rouble Rouble
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 48h
                48h
                Remaining:
                Remaining Estimate - 48h
                48h
                Logged:
                Time Spent - Not Specified
                Not Specified