SOAP:记录负载请求和响应 xml

SOAP: Log Payload Request and Response xml

我想捕获 SOAP 请求 xml 和 SOAP 响应 xml 并将其作为整个 xml 格式转储到数据库中。我的请求和响应使用负载。

下面是我的控制器

@PayloadRoot(localPart = "StudentDetailsRequest", namespace = TARGET_NAMESPACE)
public @ResponsePayload StudentDetailsResponse getStudentDetails(@RequestPayload StudentDetailsRequest request) throws Exception
{
    StudentDetailsResponse response = new StudentDetailsResponse();
    response=studentService.execute(request);
    return response;
}

请帮助实现同样的目标

提前致谢。

成功了!以下是步骤

public String getResponseXML(StudentDetailsResponse response) throws JAXBException
{
     StringWriter sw = new StringWriter();
    JAXBContext jaxbContext = JAXBContext.newInstance(StudentDetailsResponse.class);
    Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
    jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    jaxbMarshaller.marshal(response,  new StreamResult(sw));
    return sw.toString();
}