users@jax-ws.java.net

Re: How to avoid nested java types in generated exception classes (WSDL to Java)?

From: Jitendra Kotamraju <Jitendra.Kotamraju_at_Sun.COM>
Date: Fri, 08 Sep 2006 13:42:30 -0700

breadfan_at_gmx.de wrote:

>Hi!
>
>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>
>
>
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jax-ws.dev.java.net
>For additional commands, e-mail: users-help_at_jax-ws.dev.java.net
>
>