Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="https://stackoverflow.com/a/5335659/289396">Vladimir's suggestion</a> worked. This code below will help others with understanding where to put the 1000000. </p> <pre><code>public void handleMessage(SoapMessage message) throws Fault { // Get message content for dirty editing... InputStream inputStream = message.getContent(InputStream.class); if (inputStream != null) { String processedSoapEnv = ""; // Cache InputStream so it can be read independently CachedOutputStream cachedInputStream = new CachedOutputStream(1000000); try { IOUtils.copy(inputStream,cachedInputStream); inputStream.close(); cachedInputStream.close(); InputStream tmpInputStream = cachedInputStream.getInputStream(); try{ String inputBuffer = ""; int data; while((data = tmpInputStream.read()) != -1){ byte x = (byte)data; inputBuffer += (char)x; } /** * At this point you can choose to reformat the SOAP * envelope or simply view it just make sure you put * an InputStream back when you done (see below) * otherwise CXF will complain. */ processedSoapEnv = fixSoapEnvelope(inputBuffer); } catch(IOException e){ } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Re-set the SOAP InputStream with the new envelope message.setContent(InputStream.class,new ByteArrayInputStream( processedSoapEnv.getBytes())); /** * If you just want to read the InputStream and not * modify it then you just need to put it back where * it was using the CXF cached inputstream * * message.setContent(InputStream.class,cachedInputStream.getInputStream()); */ } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload