Spring WS - 无法返回JAXB响应

时间:2013-10-22 04:50:11

标签: java spring web-services

如本教程中所述:http://docs.spring.io/spring-ws/site/reference/html/tutorial.html

我有一个接收请求的Spring WS方法:

    @PayloadRoot(localPart = "HolidayRequest", namespace = NAMESPACE_URI)
@Namespace(prefix = "hr", uri= NAMESPACE_URI )
@ResponsePayload
public void handleHolidayRequest(@XPathParam("//hr:HolidayRequest") Object request) throws Exception {
    }

我可以读取传入的值。现在,如果我尝试发送响应:

    @PayloadRoot(localPart = "HolidayRequest", namespace = NAMESPACE_URI)
@Namespace(prefix = "hr", uri= NAMESPACE_URI )
@ResponsePayload
public HolidayResponse handleHolidayRequest(@XPathParam("//hr:HolidayRequest") Object request) throws Exception {
    }

    HolidayResponse response = new HolidayResponse();  // JAXB object
    response.setIsApproved( false );
    response.setEmpId( BigInteger.ONE );

    return response;

SOAP客户端收到错误响应:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring xml:lang="en">javax.xml.bind.JAXBException
     - with linked exception:
    [java.lang.NullPointerException]</faultstring>
          </SOAP-ENV:Fault>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

任何想法我可能做错了什么?

注意:我尝试包装回复:

return new JAXBElement( new QName("HolidayResponse"), HolidayResponse.class, response );

0 个答案:

没有答案