//interface to return information
OutputStream OS=message. GetContent (OutputStream. Class);
Cs=new CachedStream CachedStream ();
Message. SetContent (OutputStream class, cs);
Message. GetInterceptorChain (.) doIntercept (message);
CachedOutputStream csnew=(CachedOutputStream) message
GetContent (OutputStream. Class);
InputStream in=csnew. GetInputStream ();
//get back a message
XML=IOUtils. ToString (in);
//parsing return message
The Document Document=DocumentHelper. ParseText (XML);
CodePudding user response:
Now found that, based on the realization of the CXF web service interface returns a string is too long, can cause OutInterceptor SoapMessage buf flow of interceptor is null, if you want to analysis a Message in the interceptor, will obviously have a question, the specific reason is not found, through the analysis of the source Message. GetContent (ClassList the List=message. GetContent (List. Class);
For (Object o: list) {
System. The out. Println ("=========="+ o.g etClass ());
The Class oas=o.g etClass ();
The Field [] the fs=oas. GetDeclaredFields ();
For (int I=0; I & lt; Fs. Length; I++) {
The Field f=fs [I];
F.s etAccessible (true);
The Object val=f.g et (o);
}
CodePudding user response:
@ Override
Public void handleMessage (Message Message) throws Fault {
Try {
OutputStream OS=message. GetContent (OutputStream. Class);
ByteArrayOutputStream cs=new ByteArrayOutputStream ();
Message. SetContent (OutputStream class, cs);
Message. GetInterceptorChain (.) doIntercept (message);
ByteArrayOutputStream csnew=(ByteArrayOutputStream) message. GetContent (OutputStream. Class);
ByteArrayInputStream bis=new ByteArrayInputStream (csnew toByteArray ());
String json=IOUtils. ToString (bis);
InterfaceAccessLog InterfaceAccessLog=InterfaceAccessLogHolder. GetInterfaceAccessLog ();
InterfaceAccessLog. SetResponse (changeJsonstr (json));
InterfaceAccessLog. SetUpdatetime (new Date ());
Service. InsertInterfaceAccessLog (interfaceAccessLog);
IOUtils. Copy (new ByteArrayInputStream (json. GetBytes (" utf-8 ")), OS).
Cs. The close ();
OS. The flush ();
Message. SetContent (OutputStream class, OS);
} the catch (IOException e) {
e.printStackTrace();
}
}
The perfect solution