Hi,

In my project, I define Java first web services, and use the java2ws for
generating wsdl & xsd files. 
I face 2 issues with Exceptions that I define and use in my web service:

In my WebService I define:
public void foo2() *throws ObjectNotFoundRemoteFault*;

The exception defined in the same package as follows:
public class *ObjectNotFoundRemoteFault extends RuntimeException*

*Problem 1:* Controlling the elementFormDefault value of the xsd file of the
exceptions namespace
Although I defined package-info file with @XmlSchema(elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED), this setting seems to be
ignored

*Problem 2:* Exceptions hierarchy is not applied to the xsd. The fields of
the base exception are added to the definition of the derived exception
instead of defining <xs:extension>.
*Base exception definition*
@XmlType(name = "RemoteFault", namespace = CpmWebServices.DLE_WS_NAMESPACE)
@XmlSeeAlso(
        {
                ObjectNotFoundRemoteFault.class,
                ValidationRemoteFault.class,
                GeneralRemoteFault.class
        }
)
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class RemoteFault extends RuntimeException
{
    protected String message;
    // … getter / setter
}

*Derived exception definition*
@WebFault(name = "ObjectNotFoundRemoteFault", targetNamespace =
CpmWebServices.DLE_WS_NAMESPACE)
public class ObjectNotFoundRemoteFault extends RemoteFault
{
    private String objId;
    // … getter / setter
}

*XSD output:*
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:ns0="http://www.mycompany.com/Objects"; xmlns:tns="http://www.
mycompany.com/DleWebService" attributeFormDefault="unqualified"
elementFormDefault="unqualified" targetNamespace="http://www.
mycompany.com/DleWebService">
    <xsd:import namespace="http://www. mycompany.com/Objects"
schemaLocation="ObjectCrudSvcRemoteService_schema1.xsd"/>
    <xsd:element name="ObjectNotFoundRemoteFault"
type="tns:ObjectNotFoundRemoteFault"/>
    <xsd:complexType name="ObjectNotFoundRemoteFault">
        <xsd:sequence>
            <xsd:element name="objId" nillable="true" type="xsd:string"/>
            <xsd:element name="message" nillable="true" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="RemoteFault">
        <xsd:sequence>
            <xsd:element name="message" nillable="true" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

*My questions:*
I suspect that the exceptions schema is generated in a different way (and
not with JAXB). Is it correct?
Is there a solution for the above issues?
Is there a documentation for how java2ws handles exceptions and guidelines
(do's and dont's) for defining them in web service?

Thanks in advance, 
Arik



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Java2Ws-Wsdl-Xsd-Creation-for-Fault-Exception-tp5690471.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to