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 "Deppen, Jeff" <je...@paytec.com> on 2004/06/16 21:09:47 UTC

Interface in public web service method?

All,

Is it possible to expose a method (operation) that has an interface
parameter type?

For example, assume I have an interface and an implementing class:

public interface Foo
{
  String getName();
  void setName(String pName);
}

public class FooImpl
{
  public FooImpl()  {}
  public String getName() { return "abc";}
  public void setName(String pName) { }
}

Can I expose as a web service operation the following method?

public class MyService
{
  public MyService() {}

  public String getName(Foo aFoo)
  {
    return aFoo.getName();
  }
}

When I try to do something similar to this, I get a SAXException "Unable to
create JavaBean of type Foo.  Missing default constructor?".  Why is it
trying to create an instance of Foo instead of FooImpl - I've defined a type
mapping for Foo in my wsdd file that references FooImpl.  Here's a snippet
of my wsdd:

<service name="MyService" provider="java:RPC">
   <parameter name="className" value="MyService"/>
   <parameter name="allowedMethods" value="getName"/>
</service>

<typeMapping xmlns:ns="http://localhost:8080/myservice" qname="ns:Foo"
    type="java:FooImpl"
    serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
    deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>