Hello,

We developed a JAX-WS service with JAXB annotations on our data types. We
have been running it through the Endpoint class using the JAXB
implementation bundled with the JDK for 6 months.  I am trying to switch to
Tomcat with Axis2.  I have developed a services.xml as below, and I can see
axis2 generating a WSDL.  I have made no changes to the annotations or
anything, but am seeing very strange results in the WSDL for the XSD types.
 Here is an example:  I have a JAXB annotated class as:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "searchTermType", propOrder = {
        "fields"
})
public class SearchTerm {

    @XmlElement(name = "field", required = true)
    private List<String> fields = Lists.newArrayList();

    public SearchTerm(String... strings) {
        this(Arrays.asList(strings));
    }

    public SearchTerm(List<String> fields) {
        this.fields = fields;
    }

    public List<String> getFields() {
        return fields;
    }

    public String getFieldsAsString() {
        return StringUtils.join(getFields(), ",");
    }

    public void setFields(List<String> fields) {
        this.fields = fields;
    }

    public boolean isValid() {
        for (String s : fields) {
            if (StringUtils.isNotBlank(s))
                return true;
        }
        return false;
    }
}

In JAXB RI I get (as expected) since I have marked the @XmlAccessorType as
Field -- I get a schema like:
<xs:complexType name="searchTermType">
<xs:sequence>
<xs:element name="field" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

Note that the getFieldAsString and isValid getters are not included in the
schema.

Unfortunately, in Axis2 I get:

<xs:complexType name="SearchTerm">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="fields"
nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="fieldsAsString" nillable="true"
type="xs:string"/>
<xs:element minOccurs="0" name="valid" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>

which has included the getters -- even though I have the @XmlAccessorType as
field.  Also in general the schemas it generated are completely different --
its wrapped things in a more nested structure than the JAXB RI and used so
xs:anyType types in places -- Im just lost at how it is generating things so
differently.  So is the JAXB Provider configurable?  Can I not just
configure it to use the one bundled with the JRE?  Any thoughts?

P.S. Here is my services.xml:

<?xml version="1.0" encoding="UTF-8"?>
<serviceGroup>
  <service name="FuzzySearchService">
    <description>FuzzySearch user service</description>
    <messageReceivers>
      <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only";
class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver" />
      <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out";
class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver" />
    </messageReceivers>
    <!-- spring injection of the service from servlet context -->
    <parameter
name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
    </parameter>
    <parameter name="SpringBeanName">fuzzySearchServerService</parameter>
  </service>
  <service name="FuzzySearchAdminService">
    <description>FuzzySearch admin service</description>
    <messageReceivers>
      <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only";
class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver" />
      <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out";
class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver" />
    </messageReceivers>
  <!-- spring injection of the service from servlet context -->
    <parameter
name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
    </parameter>
    <parameter
name="SpringBeanName">fuzzySearchAdminServerService</parameter>
  </service>
</serviceGroup>

Thanks,

Steve

Reply via email to