You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Marella, Purush" <pm...@ti.com> on 2004/01/07 22:18:01 UTC

Question on using an interface as the return type for a method, i nstead of a concrete class

Hi,

 

I can use an interface as the return type just fine, but not for multiple
methods, as Axis errors out in the java2wsdl step, saying a namespace
definition is missing.  How do I specify a namespace?  The detailed
description of the problem is as follows:

 

I have 3 methods (web services) with the signatures

public Box getInbox();

public Box getOutbox();

public Box getHistory();

 

Box is an interface and BoxImpl is the concrete class that implements it.
If I have only one of the above methods, everything works fine, with only a
warning being generated, that says an xml schema anyType will be used(given
below).  But when I have all 3 methods listed out, I not only get the
warning, but followed by the error:

 

 [axis-java2wsdl] Java2WSDL com.ti.eps.nav.pet.services.box.BoxServices

[axis-java2wsdl] - The class com.ti.eps.nav.pet.box.Box does not contain a
default constructor, which is a requirement for a bean class.  The class
cannot be converted into an xml schema type.  An xml schema anyType will be
used to define this class in the wsdl file. [axis-java2wsdl] WSDLException:
faultCode=OTHER_ERROR: Can't find prefix for 'http://box.pet.nav.eps.ti.com
<http://box.pet.nav.eps.ti.com/> '. Namespace prefixes must be set on the
Definition object using the addNamespace(...) method.:

 

I tried to get around the problem by using concrete "BoxImpl" as the return
type for the methods, and everything works fine, except that wsdl2java
generator is also generating a "BoxImpl.java" class and is overwriting my
original class.

 

I would ideally like to get the code working with "Box" return type and not
the Impl.  How do I specify it the namespace it is asking for?

 

Thanks a lot for taking the time.

Purush.