private void doTestSoapConnection(boolean disableChunking) throws Exception
{
SOAPFactory soapFac = SOAPFactory.newInstance();
MessageFactory msgFac = MessageFactory.newInstance();
SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
SOAPMessage msg = msgFac.createMessage();
if (disableChunking)
{
// this is the custom header checked by ServiceImpl
msg.getMimeHeaders().addHeader("Transfer-Encoding-Disabled", "true");
// this is a hint to SOAPConnection that the chunked encoding is not needed
msg.getMimeHeaders().addHeader("Transfer-Encoding", "disabled");
}
QName sayHi = new QName("http://www.jboss.org/jbossws/saaj", "sayHello");
msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
AttachmentPart ap1 = msg.createAttachmentPart();
char[] content = new char[16 * 1024];
Arrays.fill(content, 'A');
ap1.setContent(new String(content), "text/plain");
msg.addAttachmentPart(ap1);
AttachmentPart ap2 = msg.createAttachmentPart();
ap2.setContent("Attachment content - Part 2", "text/plain");
msg.addAttachmentPart(ap2);
msg.saveChanges();
SOAPConnection con = conFac.createConnection();
final String serviceURL = "http://" + getServerHost() + ":8080/saaj-soap-connection";
URL endpoint = new URL(serviceURL);
SOAPMessage response = con.call(msg, endpoint);