Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 072C410E09 for ; Thu, 26 Sep 2013 18:41:26 +0000 (UTC) Received: (qmail 69103 invoked by uid 500); 26 Sep 2013 18:41:16 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 68889 invoked by uid 500); 26 Sep 2013 18:41:09 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 68739 invoked by uid 99); 26 Sep 2013 18:41:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Sep 2013 18:41:05 +0000 Date: Thu, 26 Sep 2013 18:41:05 +0000 (UTC) From: "Grzegorz Grzybek (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CXF-5208) Anonymous types in an exception aren't generated in WSDL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-5208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13778702#comment-13778702 ] Grzegorz Grzybek edited comment on CXF-5208 at 9/26/13 6:40 PM: ---------------------------------------------------------------- In {{org.apache.cxf.jaxb.JAXBSchemaInitializer.addElement(XmlSchema, XmlSchemaSequence, JAXBBeanInfo, QName, boolean)}} a new XSD Element is constructed when generating {{MyException}} type in {{org.apache.cxf.jaxb.JAXBSchemaInitializer.buildExceptionType(MessagePartInfo, Class)}}. {{str}} field is successfully added to the sequence particle of new Exception type, but for {{myAnonObj}} property the following code returns instead of adding new element to the sequence: {code:java} el.setName(name.getLocalPart()); Iterator itr = beanInfo.getTypeNames().iterator(); if (!itr.hasNext()) { return; } QName typeName = itr.next(); el.setSchemaTypeName(typeName); {code} {{com.redhat.samples.ws.MyAnonType}} just *don't* have XML Type name. What you have to do is to follow chapters 2.5 and 3.7 of JAX-WS 2 specifiction and instead of: {code:java} @SuppressWarnings("serial") public class MyException extends Exception { private String str; private MyAnonType myAnonObj; ... {code} you have to create: {code:java} @WebFault public class MyException extends Exception { private MyExceptionBean bean; public MyException(String message, MyExceptionBean bean) { super(message); this.bean = bean; } public MyException(String message, MyExceptionBean bean, Throwable cause) { super(message, cause); this.bean = bean; } public MyExceptionBean getFaultInfo() { return this.bean; } } {code} and one additional type: {code:java} @XmlType(name = "MyException") public class MyExceptionBean { private String str; private MyAnonType myAnonObj; public String getStr() { return str; } public void setStr(String str) { this.str = str; } public MyAnonType getMyAnonObj() { return myAnonObj; } public void setMyAnonObj(MyAnonType myAnonObj) { this.myAnonObj = myAnonObj; } } {code} {{MyAnonType}} still have {{@XmlType(name = "")}} So instead of such WSDL: {code:xml} {code} you get: {code:xml} {code} is it ok? do you agree? was (Author: gzres): In {{org.apache.cxf.jaxb.JAXBSchemaInitializer.addElement(XmlSchema, XmlSchemaSequence, JAXBBeanInfo, QName, boolean)}} a new XSD Element is constructed when generating {{MyException}} type in {{org.apache.cxf.jaxb.JAXBSchemaInitializer.buildExceptionType(MessagePartInfo, Class)}}. {{str}} field is successfully added to the sequence particle of new Exception type, but for {{myAnonObj}} property the following code returns instead of adding new element to the sequence: {code:java} el.setName(name.getLocalPart()); Iterator itr = beanInfo.getTypeNames().iterator(); if (!itr.hasNext()) { return; } QName typeName = itr.next(); el.setSchemaTypeName(typeName); {code} {{com.redhat.samples.ws.MyAnonType}} just *don't* have XML Type name. What you have to do is to follow chapters 2.5 and 3.7 of JAX-WS 2 specifiction and instead of: {code:java} @SuppressWarnings("serial") public class MyException extends Exception { private String str; private MyAnonType myAnonObj; ... {code} you have to create: {code:java} @WebFault public class MyException extends Exception { private MyExceptionBean bean; public MyException(String message, MyExceptionBean bean) { super(message); this.bean = bean; } public MyException(String message, MyExceptionBean bean, Throwable cause) { super(message, cause); this.bean = bean; } public MyExceptionBean getFaultInfo() { return this.bean; } } {code} and one additional type: {code:java} @XmlType(name = "MyException") public class MyExceptionBean { private String str; private MyAnonType myAnonObj; public String getStr() { return str; } public void setStr(String str) { this.str = str; } public MyAnonType getMyAnonObj() { return myAnonObj; } public void setMyAnonObj(MyAnonType myAnonObj) { this.myAnonObj = myAnonObj; } } {code} {{MyAnonType}} still have {{@XmlType(name = "")}} So instead of such WSDL: {code:xml} {code} you get: {code:xml} {code} > Anonymous types in an exception aren't generated in WSDL > -------------------------------------------------------- > > Key: CXF-5208 > URL: https://issues.apache.org/jira/browse/CXF-5208 > Project: CXF > Issue Type: Bug > Components: JAXB Databinding, Tooling > Affects Versions: 2.7.6 > Reporter: Tadayoshi Sato > Attachments: exception-anontype.zip > > > Anonymous types (annotated with {{@XmlType(name = "")}}) in an exception class aren't generated at all in WSDL. > Web service classes: > {code:java} > @WebService > public class GreetingService { > @WebMethod > public void hello() throws MyException {} > ... > {code} > {code:java} > public class MyException extends Exception { > private String str; > private MyAnonType myAnonObj; > public String getStr() { return str; } > public void setStr(String str) { this.str = str; } > public MyAnonType getMyAnonObj() { return myAnonObj; } > public void setMyAnonObj(MyAnonType myAnonObj) { this.myAnonObj = myAnonObj; } > ... > {code} > {code:java} > @XmlType(name = "") > public class MyAnonType { ... > {code} > Generated WSDL: > {code:xml} > > > ... > > > > > > {code} > Note that the same type ({{MyAnonType}}) is generated in WSDL if the {{@XmlType(name = "")}} annotation is removed. -- 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