0

I'd like to pass a java interface to a @Put call:

public interface IMyInterface {
...
}

public class MyClass implements IMyInterface, Serializable {
...
}

public class Service extends ServerResource {

    @Put
    public void f(IMyInterface a) {
        ...
    }

}

When I call f() through a ClientResource, I get the error message "Unsupported Media Type (415)" which I presume is because IMyInterface is not serializable.

Is it possible to pass a MyClass object as IMyInterface?

1 Answers1

0

You need to make JSON/XML serializer to work with interfces with the help of @XmlSeeAlso and @XmlJavaTypeAdapter annotations.

See:

for an example. It would not hurt to add

@Consumes("application/xml")
@Consumes("application/json")
@PUT
public void f(IMyInterface a) {
    ...
}
Community
  • 1
  • 1
Piotr Kochański
  • 21,862
  • 7
  • 70
  • 77