Hi All,
I'm having a problem with the WSDL generated from my Java code: further
passing it to WSDL2Java results in an "Error parsing WSDL". Seems like
the reason is in the new approach to custom exceptions in 1.2. Below are
the details with a very very simple example.
My service class (both methods throwing an exception):
// ===================================================
package service;
import errors.*;
public class MyService {
public String getID() throws MyServiceException {
return null;
}
public void setID(String id) throws MyServiceException {}
}
//====================================================
My exception class (in an other package, it is important! - otherwise
the problem does not emerge):
//====================================================
package errors;
public class MyServiceException extends Exception {
}
//====================================================
Applying Java2WSDL to the above code results in a WSDL, the significant
parts of which are below:
//======================================================================
================
<wsdl:definitions xmlns:axis2="http://service"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns="http://service/xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://service">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns0="http://errors/xsd"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://service/xsd">
<xs:element name="MyServiceExceptionFault">
<xs:complexType>
<xs:sequence>
<xs:element name="MyServiceException"
nillable="true"
type="ns0:MyServiceException" />
</xs:sequence>
</xs:complexType>
</xs:element>
....................................
<xs:element name="MyServiceExceptionFault">
<xs:complexType>
<xs:sequence>
<xs:element name="MyServiceException"
nillable="true"
type="ns0:MyServiceException" />
</xs:sequence>
</xs:complexType>
</xs:element>
....................................
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ax21="http://errors/xsd"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://errors/xsd">
<xs:element name="MyServiceException"
type="ax21:MyServiceException" />
<xs:complexType name="MyServiceException">
<xs:complexContent>
<xs:extension base="xs:Exception">
<xs:sequence />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
</wsdl:types>
..........................................
<wsdl:message name="MyServiceException">
<wsdl:part name="part1" element="ax21:MyServiceException" />
</wsdl:message>
..........................................
<wsdl:message name="MyServiceException">
<wsdl:part name="part1" element="ax21:MyServiceException" />
</wsdl:message>
..........................................
</wsdl:definitions>
//======================================================================
============
Applying WSDL2Java to the above WSDL results in the following error:
Exception in thread "main"
org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing
WSDL
at
org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGeneration
Engine.java:140)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:32)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:21)
Caused by: javax.wsdl.WSDLException: WSDLException (at
/wsdl:definitions/wsdl:message[3]/wsdl:part): faultCode=UNBOUND_PREFIX:
Unable to determine namespace of 'ax21:MyServiceException'.
at com.ibm.wsdl.util.xml.DOMUtils.getQName(Unknown Source)
at
com.ibm.wsdl.util.xml.DOMUtils.getQualifiedAttributeValue(Unknown
Source)
at
com.ibm.wsdl.xml.WSDLReaderImpl.getQualifiedAttributeValue(Unknown
Source)
............
Of course the MyServiceException message definition is not aware of ax21
namespace. After making the following corrections (created the global
ns2 namespace and reference it from message definitions) everything goes
ok:
//===========================================================
<wsdl:definitions xmlns:axis2="http://service"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns="http://service/xsd"
xmlns:ns2="http://errors/xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://service">
........................................................
<wsdl:message name="MyServiceException">
<wsdl:part name="part1" element="ns2:MyServiceException" />
</wsdl:message>
..........................................
<wsdl:message name="MyServiceException">
<wsdl:part name="part1" element="ns2:MyServiceException" />
</wsdl:message>
..........................................
//===========================================================
Also several more questions appear:
1) What is MyServiceExceptionFault created for? And why more than one
occurence of it (equals to number of service methods I guess...)?
2) Why is MyServiceException message created a number of times?
3) WSDL2Java complains with a warning
"WARNING: Type {http://www.w3.org/2001/XMLSchema}Exception missing!"
(it does not like "xs:Exception" MyServiceException extends). Yes it IS
missing, so no default behavior is supposed for that and I always have
to handle this issue manually?
Thanks a lot for any comments on this!!
Pavel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]