Hi Jitu,
thank you for your info.
I somehow expected this. What gave me a little hope, was the fact that if you define the exception content a little simpler (just a string, not a string and an error code in my example) like this:
<xsd:element name="myTypeException" type="xsd:string"/>
than only the exception class is generated, containing a string.
Chris
>
>We generate java classes from a given wsdl with wsimport.
>The service operations return faults with complex content (error description +
error code).
>Unfortunately jaxws always generates an exception class referencing a (generated)
java class containing the error description and the error code.
>
>Is there a way (e.g. jaxws or jaxb customization) to "flatten" this structure, so
that the generated exception directly contains the error code and the description?
>
>
I am not aware of any way to "flatten" that out. The exception class is
referring to jaxb bean so that JAXB can marshall the bean when an
exception is thrown. Since a Java exception itself doesn't conform to
java bean rules, I think spec mandates it this way.
Jitu
>I've attached a test wsdl and schema for demonstration purposes. Jaxws generates a
class "ExtestFault" (derived from Exception) which is referencing the generated
MyTypeException class which contains the descripton and the error code.
>
>Thanks in advance,
>Chris
>
>
>
>------------------------------------------------------------------------
>
><?xml version="1.0" encoding="UTF-8"?>
><wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="
http://www.example.org/extest/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema" name="extest"
> targetNamespace="http://www.example.org/extest/"
xmlns:types="
http://www.example.org/extest-schema">
> <wsdl:types>
> <xsd:schema>
> <xsd:import schemaLocation="extest.xsd"
namespace="
http://www.example.org/extest-schema" />
> </xsd:schema>
> </wsdl:types>
> <wsdl:message name="extestOperationResponse">
> <wsdl:part name="extestOperationResponse" type="xsd:int" />
> </wsdl:message>
> <wsdl:message name="extestOperationRequest">
> <wsdl:part name="extestOperationRequest" type="xsd:string" />
> </wsdl:message>
> <wsdl:message name="extest_fault">
> <wsdl:part name="extest_fault" element="types:myTypeException"/>
> </wsdl:message>
> <wsdl:portType name="extest">
> <wsdl:operation name="extestOperation">
> <wsdl:input message="tns:extestOperationRequest" />
> <wsdl:output message="tns:extestOperationResponse" />
> <wsdl:fault name="extest_fault" message="tns:extest_fault"></wsdl:fault>
> </wsdl:operation>
> </wsdl:portType>
> <wsdl:binding name="extestSOAP" type="tns:extest">
> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
> <wsdl:operation name="extestOperation">
> <soap:operation soapAction="http://www.example.org/extest/NewOperation" />
> <wsdl:input>
> <soap:body namespace="http://www.example.org/extest/" use="literal" />
> </wsdl:input>
> <wsdl:output>
> <soap:body namespace="http://www.example.org/extest/" use="literal" />
> </wsdl:output>
> <wsdl:fault name="extest_fault">
> <soap:fault name="extest_fault" use="literal"/>
> </wsdl:fault>
> </wsdl:operation>
> </wsdl:binding>
> <wsdl:service name="extest">
> <wsdl:port binding="tns:extestSOAP" name="extestSOAP">
> <soap:address location="http://www.example.org/" />
> </wsdl:port>
> </wsdl:service>
></wsdl:definitions>
>
>
>------------------------------------------------------------------------
>
><?xml version="1.0" encoding="UTF-8"?>
><schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="
http://www.example.org/extest-schema"
> xmlns:tns="http://www.example.org/extest-schema">
> <element name="myTypeException">
> <complexType>
> <sequence>
> <element name="element1" type="string"></element>
> <element name="element2" type="int"></element>
> </sequence>
> </complexType>
> </element>
></schema>
>
>
>
--
"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail