将null作为SOAP响应返回

时间:2013-01-16 11:50:17

标签: java soap null wsdl

我实施了以下服务:

@WebService
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED,
             style = SOAPBinding.Style.DOCUMENT,
             use = SOAPBinding.Use.LITERAL)
public class AccountsService {

    @WebResult
    public Account findById(@WebParam(name = "id") String id) {
        return null;
    }
}

Account是从XSD通过JAXB生成的类。

当调用AccountsService#findById时抛出异常:

Interceptor for AccountsService#findById has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault
    at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:121)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:232)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:319)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:287)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:939)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:875)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:185)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.Server.handleAsync(Server.java:391)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:443)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:922)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:780)[97:org.eclipse.jetty.http:7.4.5.fuse20111017]
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)[97:org.eclipse.jetty.http:7.4.5.fuse20111017]
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:43)[102:org.eclipse.jetty.server:7.4.5.fuse20111017]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:538)[98:org.eclipse.jetty.io:7.4.5.fuse20111017]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)[98:org.eclipse.jetty.io:7.4.5.fuse20111017]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)[103:org.eclipse.jetty.util:7.4.5.fuse20111017]
    at java.lang.Thread.run(Thread.java:662)[:1.6.0_24]
Caused by: java.lang.NullPointerException
    at ru.troika.ccit.esb.enterprise.hr.publishemployeehistory.impl.jaxws_asm.GetEmployeeByIdResponse_WrapperTypeHelper1.createWrapperObject(Unknown Source)[:]
    at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:105)[57:org.apache.cxf.bundle:2.4.3.fuse-01-02]
    ... 23 more 

是否可以将(Account)null作为回复?

注意:输出中有空Account对象不是合适的解决方案。

0 个答案:

没有答案