2015-07-13 135 views
0

我想捕獲SOAP請求xml和SOAP響應xml,並將其作爲整個xml格式轉儲到數據庫中。我使用有效載荷來處理我的請求和響應。SOAP:日誌有效負載請求和響應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; 
} 

請就如何實現同

預先感謝幫助。

回答

0

工作!以下是步驟

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(); 
} 
+0

也用於日誌記錄的結​​帳攔截器/處理程序 – ThomasRS