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