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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]