Home > Net >  Preserve New Lines When Writing MessageContext to ByteArrayOutputStream
Preserve New Lines When Writing MessageContext to ByteArrayOutputStream

Time:02-10

I have a ClientInterceptor that logs the request of each http call in my application, but it completely removes newline characters.

@Override
public boolean handleRequest( MessageContext messageContext )
   throws WebServiceClientException
{
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      messageContext.getRequest()
                    .writeTo( baos );
      logger.info( "Request to Service: {}", baos );
}

Does anyone know how to convert the request in a MessageContext to a ByteArrayOutputStream without losing newlines?

CodePudding user response:

  •  Tags:  
  • Related