You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Tom Schroedl (JIRA)" <ji...@apache.org> on 2007/10/11 01:22:50 UTC

[jira] Created: (CXF-1104) WSDLToJava Error -- two elements with the same name defined

WSDLToJava Error -- two elements with the same name defined
-----------------------------------------------------------

                 Key: CXF-1104
                 URL: https://issues.apache.org/jira/browse/CXF-1104
             Project: CXF
          Issue Type: Bug
          Components: JAXB Databinding
    Affects Versions: 2.0.2
         Environment: Java 5.
            Reporter: Tom Schroedl


The WSDL generated by my JAX-WS service cannot be used to create the client. I get the following error:

org.apache.cxf.tools.common.ToolException: WSDLToJava Error : Thrown by JAXB : 'findSystemInfoResponse' is already defined

I am trying to return a DTO from a service. The service method's return type is an interface that the DTO implements. However, while the generated client did create my exception classes, it didn't create any response classes that I was expecting. In looking at the WSDL, I noticed the response type wasn't showing up anywhere as a <xs:complexType> under <wsdl:definitions>.  So, I added @WebMethod and @ResponseWrapper(className="my.package.SysInfoDTO") to the SEI. Where SysInfoDTO is the concrete class for the return type.

Doing this did get the concrete class to show up as a complexType. However, now, when I attempt to generate the client, it fails because there are actually two elements with the same name:

<xs:complexType name="sysInfoDTO">
   <xs:sequence>
      <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
      <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
      <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
   </xs:sequence>
</xs:complexType>
<xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
...
<xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
<xs:complexType name="findSystemInfoResponse">
   <xs:sequence>
      <xs:element minOccurs="0" name="result"/>
   </xs:sequence>
</xs:complexType>

I can see why this would fail as it can't figure out which findSystemInfoResponse element to use.  Is there something I've missed, should this happen?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-1104) WSDLToJava Error -- two elements with the same name defined

Posted by "Tom Schroedl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534059 ] 

Tom Schroedl commented on CXF-1104:
-----------------------------------

I am using Spring to configure the service. Looks like:
...
<jaxws:endpoint>
   id="sysInfoFacadeCXFServiceEndpoint"
   implementorClass="apup.facade.impl.SysInfoFacadeImpl"
   implementor="#sysInfoFacadeImpl"       <--- this is a Spring bean I'm injecting
   address="/SysInfoFacade"/>

The format of the URL I'm using to generate the WSDL:

https://localhost/app/service/cxf/SysInfoFacade?wsdl
which imports
https://localhost/app/service/cxf/SysInfoFacade?wsdl=SysInfoFacade.wsdl





> WSDLToJava Error -- two elements with the same name defined
> -----------------------------------------------------------
>
>                 Key: CXF-1104
>                 URL: https://issues.apache.org/jira/browse/CXF-1104
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.0.2
>         Environment: Java 5.
>            Reporter: Tom Schroedl
>
> The WSDL generated by my JAX-WS service cannot be used to create the client. I get the following error:
> org.apache.cxf.tools.common.ToolException: WSDLToJava Error : Thrown by JAXB : 'findSystemInfoResponse' is already defined
> I am trying to return a DTO from a service. The service method's return type is an interface that the DTO implements. However, while the generated client did create my exception classes, it didn't create any response classes that I was expecting. In looking at the WSDL, I noticed the response type wasn't showing up anywhere as a <xs:complexType> under <wsdl:definitions>.  So, I added @WebMethod and @ResponseWrapper(className="my.package.SysInfoDTO") to the SEI. Where SysInfoDTO is the concrete class for the return type.
> Doing this did get the concrete class to show up as a complexType. However, now, when I attempt to generate the client, it fails because there are actually two elements with the same name:
> <xs:complexType name="sysInfoDTO">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
>    </xs:sequence>
> </xs:complexType>
> <xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
> ...
> <xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
> <xs:complexType name="findSystemInfoResponse">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="result"/>
>    </xs:sequence>
> </xs:complexType>
> I can see why this would fail as it can't figure out which findSystemInfoResponse element to use.  Is there something I've missed, should this happen?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-1104) WSDLToJava Error -- two elements with the same name defined

Posted by "maomaode (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533921 ] 

maomaode commented on CXF-1104:
-------------------------------

Question: 
* Which findSystemInfoResponse element do you expect the tools to pick up?
* Is it possible to resolve the confusion by modifying the schema and wsdl?


> WSDLToJava Error -- two elements with the same name defined
> -----------------------------------------------------------
>
>                 Key: CXF-1104
>                 URL: https://issues.apache.org/jira/browse/CXF-1104
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.0.2
>         Environment: Java 5.
>            Reporter: Tom Schroedl
>
> The WSDL generated by my JAX-WS service cannot be used to create the client. I get the following error:
> org.apache.cxf.tools.common.ToolException: WSDLToJava Error : Thrown by JAXB : 'findSystemInfoResponse' is already defined
> I am trying to return a DTO from a service. The service method's return type is an interface that the DTO implements. However, while the generated client did create my exception classes, it didn't create any response classes that I was expecting. In looking at the WSDL, I noticed the response type wasn't showing up anywhere as a <xs:complexType> under <wsdl:definitions>.  So, I added @WebMethod and @ResponseWrapper(className="my.package.SysInfoDTO") to the SEI. Where SysInfoDTO is the concrete class for the return type.
> Doing this did get the concrete class to show up as a complexType. However, now, when I attempt to generate the client, it fails because there are actually two elements with the same name:
> <xs:complexType name="sysInfoDTO">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
>    </xs:sequence>
> </xs:complexType>
> <xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
> ...
> <xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
> <xs:complexType name="findSystemInfoResponse">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="result"/>
>    </xs:sequence>
> </xs:complexType>
> I can see why this would fail as it can't figure out which findSystemInfoResponse element to use.  Is there something I've missed, should this happen?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-1104) WSDLToJava Error -- two elements with the same name defined

Posted by "Tom Schroedl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533941 ] 

Tom Schroedl commented on CXF-1104:
-----------------------------------

I was expecting the result of the call to be the same type as that specified by the SEI, which would be my.package.SysInfoDTO. The complexType named sysInfoDTO contains the elements corresponding to the data I was expecting to retrieve (applicationVersion, currentDatabase, currentSchema).

Yes, I tried modifying the WSDL manually to remove the confusion. I was able to get WSDLToJava to generate the client files by renaming as follows:

<xs:complexType name="sysInfoDTO">
   <xs:sequence>
      <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
      <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
      <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
   </xs:sequence>
</xs:complexType>
<xs:element name="sysInfo" nillable="true" type="sysInfoDTO"/>
...
<xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
<xs:complexType name="findSystemInfoResponse">
   <xs:sequence>
      <xs:element minOccurs="0" name="sysInfo"/>
   </xs:sequence>
</xs:complexType> 

However, the subsequent service call fails. I then tried to achieve this result by adding an annotation on the SEI so that the generated WSDL would match. I added a @WebResult(name="sysInfo"). This made the above look like:

<xs:complexType name="sysInfoDTO">
   <xs:sequence>
      <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
      <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
      <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
   </xs:sequence>
</xs:complexType>
<xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
...
<xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
<xs:complexType name="findSystemInfoResponse">
   <xs:sequence>
      <xs:element minOccurs="0" name="sysInfo"/>   <---- this changed to match the WebResult name
   </xs:sequence>
</xs:complexType> 

Close, but there's still the duplicate findSystemInfoResponse element.  

I would really prefer to fix it via configuration/annotation since the WSDL is being generated. I've used Aegis binding in the past with XFire and had it working, but there is no client code generation for Aegis from the WSDL (yet) that I know of. I want to be able to give my WSDL to customers and have them be able to generate the client without asking me for anything.


> WSDLToJava Error -- two elements with the same name defined
> -----------------------------------------------------------
>
>                 Key: CXF-1104
>                 URL: https://issues.apache.org/jira/browse/CXF-1104
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.0.2
>         Environment: Java 5.
>            Reporter: Tom Schroedl
>
> The WSDL generated by my JAX-WS service cannot be used to create the client. I get the following error:
> org.apache.cxf.tools.common.ToolException: WSDLToJava Error : Thrown by JAXB : 'findSystemInfoResponse' is already defined
> I am trying to return a DTO from a service. The service method's return type is an interface that the DTO implements. However, while the generated client did create my exception classes, it didn't create any response classes that I was expecting. In looking at the WSDL, I noticed the response type wasn't showing up anywhere as a <xs:complexType> under <wsdl:definitions>.  So, I added @WebMethod and @ResponseWrapper(className="my.package.SysInfoDTO") to the SEI. Where SysInfoDTO is the concrete class for the return type.
> Doing this did get the concrete class to show up as a complexType. However, now, when I attempt to generate the client, it fails because there are actually two elements with the same name:
> <xs:complexType name="sysInfoDTO">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
>    </xs:sequence>
> </xs:complexType>
> <xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
> ...
> <xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
> <xs:complexType name="findSystemInfoResponse">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="result"/>
>    </xs:sequence>
> </xs:complexType>
> I can see why this would fail as it can't figure out which findSystemInfoResponse element to use.  Is there something I've missed, should this happen?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-1104) WSDLToJava Error -- two elements with the same name defined

Posted by "Tom Schroedl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534071 ] 

Tom Schroedl commented on CXF-1104:
-----------------------------------

The same issue occurs if I generate the WSDL using org.apache.cxf.tools.java2wsdl.JavaToWSDL. 

I.e, the error is because a schema cannot contain two global components with the same name. There are two occurrences of findSystemInfoResponse in the target namespace.



> WSDLToJava Error -- two elements with the same name defined
> -----------------------------------------------------------
>
>                 Key: CXF-1104
>                 URL: https://issues.apache.org/jira/browse/CXF-1104
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.0.2
>         Environment: Java 5.
>            Reporter: Tom Schroedl
>
> The WSDL generated by my JAX-WS service cannot be used to create the client. I get the following error:
> org.apache.cxf.tools.common.ToolException: WSDLToJava Error : Thrown by JAXB : 'findSystemInfoResponse' is already defined
> I am trying to return a DTO from a service. The service method's return type is an interface that the DTO implements. However, while the generated client did create my exception classes, it didn't create any response classes that I was expecting. In looking at the WSDL, I noticed the response type wasn't showing up anywhere as a <xs:complexType> under <wsdl:definitions>.  So, I added @WebMethod and @ResponseWrapper(className="my.package.SysInfoDTO") to the SEI. Where SysInfoDTO is the concrete class for the return type.
> Doing this did get the concrete class to show up as a complexType. However, now, when I attempt to generate the client, it fails because there are actually two elements with the same name:
> <xs:complexType name="sysInfoDTO">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
>    </xs:sequence>
> </xs:complexType>
> <xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
> ...
> <xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
> <xs:complexType name="findSystemInfoResponse">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="result"/>
>    </xs:sequence>
> </xs:complexType>
> I can see why this would fail as it can't figure out which findSystemInfoResponse element to use.  Is there something I've missed, should this happen?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-1104) WSDLToJava Error -- two elements with the same name defined

Posted by "Tom Schroedl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534567 ] 

Tom Schroedl commented on CXF-1104:
-----------------------------------


It indeed appears that JAXB cannot bind interfaces out of the box. The JAXB guide linked to off the CXF website provides some ways to handle interfaces via annotations.

https://jaxb.dev.java.net/guide/Mapping_interfaces.html

Haven't tried their suggestions yet, but I will. If anyone already has a working example of this, would be a nice addition to the samples or website.




> WSDLToJava Error -- two elements with the same name defined
> -----------------------------------------------------------
>
>                 Key: CXF-1104
>                 URL: https://issues.apache.org/jira/browse/CXF-1104
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.0.2
>         Environment: Java 5.
>            Reporter: Tom Schroedl
>
> The WSDL generated by my JAX-WS service cannot be used to create the client. I get the following error:
> org.apache.cxf.tools.common.ToolException: WSDLToJava Error : Thrown by JAXB : 'findSystemInfoResponse' is already defined
> I am trying to return a DTO from a service. The service method's return type is an interface that the DTO implements. However, while the generated client did create my exception classes, it didn't create any response classes that I was expecting. In looking at the WSDL, I noticed the response type wasn't showing up anywhere as a <xs:complexType> under <wsdl:definitions>.  So, I added @WebMethod and @ResponseWrapper(className="my.package.SysInfoDTO") to the SEI. Where SysInfoDTO is the concrete class for the return type.
> Doing this did get the concrete class to show up as a complexType. However, now, when I attempt to generate the client, it fails because there are actually two elements with the same name:
> <xs:complexType name="sysInfoDTO">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
>    </xs:sequence>
> </xs:complexType>
> <xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
> ...
> <xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
> <xs:complexType name="findSystemInfoResponse">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="result"/>
>    </xs:sequence>
> </xs:complexType>
> I can see why this would fail as it can't figure out which findSystemInfoResponse element to use.  Is there something I've missed, should this happen?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-1104) WSDLToJava Error -- two elements with the same name defined

Posted by "Tom Schroedl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-1104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534185 ] 

Tom Schroedl commented on CXF-1104:
-----------------------------------

The error goes away running JavaToWSDL if I set the -t option (specifies the target namespace to use in the generated WSDL file) and change my SEI method to return a concrete class instead of an interface. With the generated WSDL, I can then generate the client using WSDLToJava. This client works and I get the data back.

I would have thought the @ResponseWrapper(className="...") annotation would do the trick. Had to actually change the return type to a concrete class. I'm stumped that I can't have an interface as a return type. Am I making a configuration mistake, or is there a way around this? 



> WSDLToJava Error -- two elements with the same name defined
> -----------------------------------------------------------
>
>                 Key: CXF-1104
>                 URL: https://issues.apache.org/jira/browse/CXF-1104
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.0.2
>         Environment: Java 5.
>            Reporter: Tom Schroedl
>
> The WSDL generated by my JAX-WS service cannot be used to create the client. I get the following error:
> org.apache.cxf.tools.common.ToolException: WSDLToJava Error : Thrown by JAXB : 'findSystemInfoResponse' is already defined
> I am trying to return a DTO from a service. The service method's return type is an interface that the DTO implements. However, while the generated client did create my exception classes, it didn't create any response classes that I was expecting. In looking at the WSDL, I noticed the response type wasn't showing up anywhere as a <xs:complexType> under <wsdl:definitions>.  So, I added @WebMethod and @ResponseWrapper(className="my.package.SysInfoDTO") to the SEI. Where SysInfoDTO is the concrete class for the return type.
> Doing this did get the concrete class to show up as a complexType. However, now, when I attempt to generate the client, it fails because there are actually two elements with the same name:
> <xs:complexType name="sysInfoDTO">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="applicationVersion" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentDatabase" type="xs:string"/>
>       <xs:element minOccurs="0" name="currentSchema" type="xs:string"/>
>    </xs:sequence>
> </xs:complexType>
> <xs:element name="findSystemInfoResponse" nillable="true" type="sysInfoDTO"/>
> ...
> <xs:element name="findSystemInfoResponse" type="findSystemInfoResponse"/>
> <xs:complexType name="findSystemInfoResponse">
>    <xs:sequence>
>       <xs:element minOccurs="0" name="result"/>
>    </xs:sequence>
> </xs:complexType>
> I can see why this would fail as it can't figure out which findSystemInfoResponse element to use.  Is there something I've missed, should this happen?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.