You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Leon Searl <se...@ittc.ku.edu> on 2007/12/05 18:34:01 UTC

different java package for wsdl2java generated fault classes (Axis2 1.3)

Hi,

I've been using Axis2 v1.3 and wsdl2java with the ADB binding
to create the classes for my services and clients. This has worked
pretty well for me. But I would like to have wsdl2java do one
thing different.

wsdl2java puts the classes for faults into the same java package as the
service skeleton reguardless of the namespace that the fault name
is in.

Is there a way to have a wsdl2java generated fault class package
be based on the namespace of the wsdl fault name?

The rational for wanting this would be cumbersome to explain so
I've left it out of this message. But I will way that it will
allow me to modularize/reuse wsdl 'interfaces' that include faults.
I can provide the rational for anyone that wants it.

Thanks for any information/help you can provide.

leon

-- 
Leon S. Searl, Software Research Engineer
Information and Telecommunication Technology Center, University of Kansas
Nichols Hall, 2335 Irving Hill Road, Lawrence, KS 66045-7612
Ph: 785-864-7820     Fax: 785-864-0387
http://www.ittc.ku.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: different java package for wsdl2java generated fault classes (Axis2 1.3)

Posted by Leon Searl <se...@ittc.ku.edu>.
Hi Mauro,

I completely agree with what you have said here.

I even looked at the wsdl2java code generator to see if there was a way
to customize the package of the fault class. As you say, it is coded
to only be determined by the wsdl targetnamespace.

I've considered the manual refactoring that you mentioned. It is a
possibility. But I am lazy.

I'm going to toy with the idea
of patching the wsdl2java code to give me the option
to have the package of the fault class be determined by the namespace
of the fault. I've looked at the code and I believe that it is
very doable.

Would anyone else be interested in this?

Thanks for your input.

leon

Mauro Molinari wrote:
> Amila Suriarachchi ha scritto:
>> fault class package is based on the wsdl targetnamespace. try to 
>> codegen using the -p option to
>> specify an different package for wsdl namesapce components.
> 
> If I understood Leon right, he means that exception classes are 
> generated in the same package of the skeleton, that is the target 
> namespace of the wsdl.
> 
> Leon, from my experience, WSDL2Java behaves as follows:
> 
> - it generates an ADBBean for the type defined in the schema 
> corresponding to the description of the fault message: this class is put 
> in the package corresponding to the target namespace of the schema
> - it generates an exception class with the same name of the <wsdl:fault> 
> defined for an operation: this class is put in the package corresponding 
> to the target namespace of the package
> 
> Example:
> Suppose in your WSDL you have:
> <wsdl:operation name="myOp">
>   <wsdl:input message="wsdl:myOpRequest"></wsdl:input>
>   <wsdl:output message="wsdl:myOpResponse"></wsdl:output>
>   <wsdl:fault name="MyException"
>     message="wsdl:MyException">
>   </wsdl:fault>
> </wsdl:operation>
> 
> and:
> <wsdl:message name="MyException">
>   <wsdl:part name="parameters"
>     element="schema:MyFaultMessage">
>   </wsdl:part>
> </wsdl:message>
> 
> while, in the schema, you have:
> <element name="MyFaultMessage">
>   <complexType>
>     <sequence>
>       <!-- [cut] -->
>     </sequence>
>   </complexType>
> </element>
> 
> Now, suppose the namespaces are as follows:
> - prefix "schema" = target namespace of the schema = 
> http://myhost.com/MyService/type
> - prefix "wsdl" = target namespace of the WSDL = 
> http://myhost.com/MyService/wsdl
> 
> WSDL2Java generates the following:
> - com.myhost.myservice.type.MyFaultMessage, which is an ADBBean 
> describing the details of the fault message
> - com.myhost.myservice.wsdl.MyException, which is an extension of 
> java.lang.Exception, with a property named "faultMessage" of type 
> MyFaultMessage
> 
> The skeleton is also put in com.myhost.myservice.wsdl. I don't think 
> this is customizable at the moment. If you want to share the same 
> exceptions and faults within multiple services, I did as follows:
> - I created a common XSD schema, that I import in every WSDL
> - in this schema, there's a global element defined which describes my 
> fault message
> - the schema has a target namespace which is mapped to the package 
> containing types that I want to share between services implementations
> - then, I manually created an extension of java.lang.Exception with a 
> property (+ getter/setter) of the type of the fault message and I put 
> this exception in another shared package
> - then, every time I generate a new web service skeleton, I delete the 
> generated exceptions and refactor the skeleton and the message receiver 
> so that they use the shared exception defined manually, instead of the 
> auto-generated ones
> 
> Obviously, this is a problem if you want (or need) to completely rely on 
> auto-generation.
> 
> Hope this helps.
> 

-- 
Leon S. Searl, Software Research Engineer
Information and Telecommunication Technology Center, University of Kansas
Nichols Hall, 2335 Irving Hill Road, Lawrence, KS 66045-7612
Ph: 785-864-7820     Fax: 785-864-0387
http://www.ittc.ku.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: different java package for wsdl2java generated fault classes (Axis2 1.3)

Posted by Mauro Molinari <ma...@cardinis.com>.
Amila Suriarachchi ha scritto:
> fault class package is based on the wsdl targetnamespace. try to codegen 
> using the -p option to
> specify an different package for wsdl namesapce components.

If I understood Leon right, he means that exception classes are 
generated in the same package of the skeleton, that is the target 
namespace of the wsdl.

Leon, from my experience, WSDL2Java behaves as follows:

- it generates an ADBBean for the type defined in the schema 
corresponding to the description of the fault message: this class is put 
in the package corresponding to the target namespace of the schema
- it generates an exception class with the same name of the <wsdl:fault> 
defined for an operation: this class is put in the package corresponding 
to the target namespace of the package

Example:
Suppose in your WSDL you have:
<wsdl:operation name="myOp">
   <wsdl:input message="wsdl:myOpRequest"></wsdl:input>
   <wsdl:output message="wsdl:myOpResponse"></wsdl:output>
   <wsdl:fault name="MyException"
     message="wsdl:MyException">
   </wsdl:fault>
</wsdl:operation>

and:
<wsdl:message name="MyException">
   <wsdl:part name="parameters"
     element="schema:MyFaultMessage">
   </wsdl:part>
</wsdl:message>

while, in the schema, you have:
<element name="MyFaultMessage">
   <complexType>
     <sequence>
       <!-- [cut] -->
     </sequence>
   </complexType>
</element>

Now, suppose the namespaces are as follows:
- prefix "schema" = target namespace of the schema = 
http://myhost.com/MyService/type
- prefix "wsdl" = target namespace of the WSDL = 
http://myhost.com/MyService/wsdl

WSDL2Java generates the following:
- com.myhost.myservice.type.MyFaultMessage, which is an ADBBean 
describing the details of the fault message
- com.myhost.myservice.wsdl.MyException, which is an extension of 
java.lang.Exception, with a property named "faultMessage" of type 
MyFaultMessage

The skeleton is also put in com.myhost.myservice.wsdl. I don't think 
this is customizable at the moment. If you want to share the same 
exceptions and faults within multiple services, I did as follows:
- I created a common XSD schema, that I import in every WSDL
- in this schema, there's a global element defined which describes my 
fault message
- the schema has a target namespace which is mapped to the package 
containing types that I want to share between services implementations
- then, I manually created an extension of java.lang.Exception with a 
property (+ getter/setter) of the type of the fault message and I put 
this exception in another shared package
- then, every time I generate a new web service skeleton, I delete the 
generated exceptions and refactor the skeleton and the message receiver 
so that they use the shared exception defined manually, instead of the 
auto-generated ones

Obviously, this is a problem if you want (or need) to completely rely on 
auto-generation.

Hope this helps.

-- 
Mauro Molinari
Software Developer
mauro.molinari@cardinis.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: different java package for wsdl2java generated fault classes (Axis2 1.3)

Posted by Amila Suriarachchi <am...@gmail.com>.
On Dec 5, 2007 11:04 PM, Leon Searl <se...@ittc.ku.edu> wrote:

> Hi,
>
> I've been using Axis2 v1.3 and wsdl2java with the ADB binding
> to create the classes for my services and clients. This has worked
> pretty well for me. But I would like to have wsdl2java do one
> thing different.
>
> wsdl2java puts the classes for faults into the same java package as the
> service skeleton reguardless of the namespace that the fault name
> is in.
>
> Is there a way to have a wsdl2java generated fault class package
> be based on the namespace of the wsdl fault name?

fault class package is based on the wsdl targetnamespace. try to codegen
using the -p option to
specify an different package for wsdl namesapce components.

Thanks,
Amila.

>
>
> The rational for wanting this would be cumbersome to explain so
> I've left it out of this message. But I will way that it will
> allow me to modularize/reuse wsdl 'interfaces' that include faults.
> I can provide the rational for anyone that wants it.
>
> Thanks for any information/help you can provide.
>
> leon
>
> --
> Leon S. Searl, Software Research Engineer
> Information and Telecommunication Technology Center, University of Kansas
> Nichols Hall, 2335 Irving Hill Road, Lawrence, KS 66045-7612
> Ph: 785-864-7820     Fax: 785-864-0387
> http://www.ittc.ku.edu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Amila Suriarachchi,
WSO2 Inc.