Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.4.4
-
None
-
Unknown
Description
Jaxws 2.2 section 5.1.1 states:
"When an invoke method returns null, it is considered that no response needs to be sent by service."
This use case assumes there is no information about the operation's MEP (no wsdl, no java annotation).
CXF currently is throwing an exception in this case as it tries to serialize the null object in its response (or outbound) chain processing.
21.11.2011 11:56:08 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNUNG: Interceptor for
GreeterService#
{http://server.any.test.tmp/}invoke has thrown exception, unwinding now
java.lang.NullPointerException
at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:418)
at org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:88)
at org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:50)
at org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:46)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:119)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
...
To support the behavior given by the above paragraph, we need to handle this condition, whether a provider based service is returning a null, and if so, return no response content (i.e, HTTP 202 with no content) instead of throwing an exception and returning a SOAP fault.
To be compatible with the old behavior (i.e, throwing an exception), we can introduce a runtime property to enable or disable this provider's null response behavior.