You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ceineke <ch...@ek3.com> on 2012/06/15 16:35:22 UTC

Generated wsdl includes XSD schema twice

CXF v2.5.3
Spring v3.1.1.RELEASE

I've annotated a class with @WebService(name="..."), annotated methods with
@WebMethod(operationName="...", action="..."), and annotated method
parameters (one per method) with @WebParam(name="...").

The method parameters are classes generated by the maven-jaxb2-plugin from
an XSD and annotated as such.

The generated WSDL contains some types and elements from the XSD schema in
the wsdl:types section twice ("..." denotes the same namespace):

<wsdl:types>
  <xs:schema xmlns:tns="..." xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" targetNamespace="..." version="1.0">
    <xs:element name="a">
      <xs:complexType>
        <xs:sequence>
          <xs:element maxOccurs="unbounded" name="b" type="tns:b"/>
          <xs:element maxOccurs="unbounded" name="c" type="tns:c"/>
          <xs:element maxOccurs="unbounded" name="d" type="tns:d"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    ...
  </xs:schema>
  <xs:schema xmlns:ns1="..." xmlns:tns="..."
xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="...">
    <xs:import namespace="..."/>
    <xs:element name="foo" type="tns:foo"/>
    ...
    <xs:complexType name="foo">
      <xs:sequence>
        <xs:element minOccurs="0" name="a">
          <xs:complexType>
            <xs:sequence>
              <xs:element form="qualified" maxOccurs="unbounded"
minOccurs="0" name="a">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element form="qualified" maxOccurs="unbounded"
name="a" type="ns1:a"/>
                    <xs:element form="qualified" maxOccurs="unbounded"
name="b" type="ns1:b"/>
                    <xs:element form="qualified" maxOccurs="unbounded"
name="c" type="ns1:c"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    ...
 </xs:schema>
</wsdl:types>

I define my bean service following way:

<bean id="bar" class="com.foo.SoapService" scope="request">
  <aop:scoped-proxy/>
</bean>
<jaxws:endpoint id="barSoap" implementor="#bar"
implementorClass="com.foo.SoapService" address="/soap"/>

I expected the second schema (which defines the elements of the SOAP
operations) not to repeat the schema but reference the elements and types
from previous one. Is this a bug or am I expecting the wrong thing?

- chris

--
View this message in context: http://cxf.547215.n5.nabble.com/Generated-wsdl-includes-XSD-schema-twice-tp5709876.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Generated wsdl includes XSD schema twice

Posted by Daniel Kulp <dk...@apache.org>.
> I expected the second schema (which defines the elements of the SOAP
> operations) not to repeat the schema but reference the elements and types
> from previous one. Is this a bug or am I expecting the wrong thing?

Kind of depends on the annotations you have on the types.   In particular, 
it looks like you have @XmlRootElement annotations on them, but NOT @XmlType 
annotations (or @XmlType(name="") ) which creates the anonymous types.  In 
JAXWS, when creating the operation wrapper types, we have to use types only, 
not element refs.   Thus, if the original class doesn't allow a type, JAXB 
more or less duplicates it.   If you add @XmlType(name="a") to the types, it 
will likely fix this.

Dan



On Friday, June 15, 2012 07:35:22 AM ceineke wrote:
> CXF v2.5.3
> Spring v3.1.1.RELEASE
> 
> I've annotated a class with @WebService(name="..."), annotated methods
> with @WebMethod(operationName="...", action="..."), and annotated method
> parameters (one per method) with @WebParam(name="...").
> 
> The method parameters are classes generated by the maven-jaxb2-plugin from
> an XSD and annotated as such.
> 
> The generated WSDL contains some types and elements from the XSD schema in
> the wsdl:types section twice ("..." denotes the same namespace):
> 
> <wsdl:types>
>   <xs:schema xmlns:tns="..." xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" targetNamespace="..." version="1.0">
>     <xs:element name="a">
>       <xs:complexType>
>         <xs:sequence>
>           <xs:element maxOccurs="unbounded" name="b" type="tns:b"/>
>           <xs:element maxOccurs="unbounded" name="c" type="tns:c"/>
>           <xs:element maxOccurs="unbounded" name="d" type="tns:d"/>
>         </xs:sequence>
>       </xs:complexType>
>     </xs:element>
>     ...
>   </xs:schema>
>   <xs:schema xmlns:ns1="..." xmlns:tns="..."
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> attributeFormDefault="unqualified" elementFormDefault="unqualified"
> targetNamespace="...">
>     <xs:import namespace="..."/>
>     <xs:element name="foo" type="tns:foo"/>
>     ...
>     <xs:complexType name="foo">
>       <xs:sequence>
>         <xs:element minOccurs="0" name="a">
>           <xs:complexType>
>             <xs:sequence>
>               <xs:element form="qualified" maxOccurs="unbounded"
> minOccurs="0" name="a">
>                 <xs:complexType>
>                   <xs:sequence>
>                     <xs:element form="qualified" maxOccurs="unbounded"
> name="a" type="ns1:a"/>
>                     <xs:element form="qualified" maxOccurs="unbounded"
> name="b" type="ns1:b"/>
>                     <xs:element form="qualified" maxOccurs="unbounded"
> name="c" type="ns1:c"/>
>                   </xs:sequence>
>                 </xs:complexType>
>               </xs:element>
>             </xs:sequence>
>           </xs:complexType>
>         </xs:element>
>       </xs:sequence>
>     </xs:complexType>
>     ...
>  </xs:schema>
> </wsdl:types>
> 
> I define my bean service following way:
> 
> <bean id="bar" class="com.foo.SoapService" scope="request">
>   <aop:scoped-proxy/>
> </bean>
> <jaxws:endpoint id="barSoap" implementor="#bar"
> implementorClass="com.foo.SoapService" address="/soap"/>
> 
> I expected the second schema (which defines the elements of the SOAP
> operations) not to repeat the schema but reference the elements and types
> from previous one. Is this a bug or am I expecting the wrong thing?
> 
> - chris
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Generated-wsdl-includes-XSD-schema-twice-
> tp5709876.html Sent from the cxf-user mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com