Java Web Services / JAXB – Abstract superclasses
•
Java
I have a package containing JAXB annotation classes and an abstract superclass I want to use this superclass in the web service interface, so I
javax.xml.ws.WebServiceException: javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.bind.UnmarshalException: Unable to create an instance of xxx.yyy.ZZZ - with linked exception: [java.lang.InstantiationException]]
You can manually group / split & pass parameters as a string, but I want to avoid it What do you think?
Solution
Do you specify a specific implementation in the web service request? This is good for me:
Abstract base class:
@XmlSeeAlso({Foo.class,Bar.class})
public abstract class FooBase
{
...
}
Implementation:
@XmlRootElement(name = "foo")
public class Foo extends FooBase
{
...
}
Web service mode:
public String getFoo(@WebParam(name = "param") final FooBase foo)
{
...
}
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.example/">
<soapenv:Header/>
<soapenv:Body>
<ser:getFoo>
<param xsi:type="ser:foo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ser:getFoo>
</soapenv:Body>
</soapenv:Envelope>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
