I thought I'd add some sample code:

My superclass:

@XmlType
public abstract class ServiceRequest {
        private String ssid;

        @XmlAttribute
        public String getSsid() {
                return ssid;
        }

        public void setSsid(String ssid) {
                this.ssid = ssid;
        }
}

My impl class:

@XmlRootElement //I have tried both @XmlType and nothing here, no luck
public class ListServersRequest extends ServiceRequest {

}

My service method:

    @Post
    @HttpResource(location = "/listServers")
    @WebResult (name = "ListServersResponse")
.    ListServersResponse listServers(ListServersRequest request);

It never reaches the method. I get the following error:

INFO: Invoking POST on /listServers
Apr 4, 2008 10:03:55 PM org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor handleMessage INFO: URIParameterInterceptor handle message on path [/listServers] with content-type [application/xml] Apr 4, 2008 10:03:55 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
at org .apache .cxf .binding .http.IriDecoderHelper.interopolateParams(IriDecoderHelper.java:306) at org .apache .cxf .binding .http .interceptor .URIParameterInInterceptor.mergeParams(URIParameterInInterceptor.java: 122) at org .apache .cxf .binding .http .interceptor .URIParameterInInterceptor .handleMessage(URIParameterInInterceptor.java:103) at org .apache .cxf .phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:208) at org .apache .cxf .transport .ChainInitiationObserver.onMessage(ChainInitiationObserver.java:77) at org .apache .cxf .transport .servlet.ServletDestination.doMessage(ServletDestination.java:79) at org .apache .cxf .transport .servlet.ServletController.invokeDestination(ServletController.java:264) at org .apache .cxf.transport.servlet.ServletController.invoke(ServletController.java: 123) at org .apache .cxf .transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java: 170) at org .apache .cxf .transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java: 148)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org .apache .catalina .core .ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java: 290) at org .apache .catalina .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org .apache .catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 233) at org .apache .catalina.core.StandardContextValve.invoke(StandardContextValve.java: 175) at org .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java: 128) at org .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java: 102) at org .apache .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java: 286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java: 844) at org.apache.coyote.http11.Http11Protocol $Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java: 447)
        at java.lang.Thread.run(Unknown Source)


If I rip the content from ServiceResponse and put it directly into ListServersResponse, everything works. Otherwise, everything fails. If anyone has any clue, I'd appreciate the help!

Brad

On Apr 4, 2008, at 6:47 PM, Brad O'Hearne wrote:

Hello,

I am using CXF with RESTful services, configured with Spring. My request objects (parameters to my service methods) and response objects (return types on my service methods) have a common structure, so I created some base classes with common members, which the actual request and response objects I use and declare as types in my service interface method signatures, and have discovered something horrible...which I hope is something only as horrible as my lack of knowledge on how to change the default behavior. Apparently, all members defined on the base classes are ignored when the serialization / deserialization binding occurs, and I receive NullPointerExceptions. If I take all the members defined in my base classes and stuff them into their subclasses, everything works fine. Obviously, this is a bad scene, as it requires me to duplicate code across every request and response object, respectively.

How do I alter the CXF behavior (using JAXB) so that I can have my request and response types extend from base classes and have those base class members serialize and deserialize properly?

Thanks,

Brad

Reply via email to