Here you can find the source of toByteArray(SOAPMessage soapMessage)
public static byte[] toByteArray(SOAPMessage soapMessage) throws Exception
//package com.java2s; //License from project: Apache License import javax.xml.soap.SOAPMessage; import java.io.ByteArrayOutputStream; public class Main { public static byte[] toByteArray(SOAPMessage soapMessage) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); soapMessage.writeTo(bos);/*w w w . j a v a 2 s .co m*/ return bos.toByteArray(); } }