}
public void test(boolean chunking)
throws Exception
{
Client client = new Client(service.getBinding(SoapHttpTransport.SOAP11_HTTP_BINDING),
"http://localhost:8191/AttachmentEcho");
client.setProperty(HttpTransport.CHUNKING_ENABLED, new Boolean(chunking).toString());
File f = getTestFile("src/test/org/codehaus/xfire/attachments/echo11.xml");
FileDataSource fs = new FileDataSource(f);
final DataHandler dh = new DataHandler(fs);
client.addOutHandler(new AbstractHandler() {
public void invoke(MessageContext context)
throws Exception
{
Attachments atts = new JavaMailAttachments();
atts.addPart(new SimpleAttachment("test.jpg", dh));
context.getOutMessage().setAttachments(atts);
}
});
client.addInHandler(new AbstractHandler() {
public void invoke(MessageContext context)
throws Exception
{
Attachments atts = context.getInMessage().getAttachments();
assertEquals(1, atts.size());
Attachment att = atts.getPart("test.jpg");
assertNotNull(att);
}
});
client.invoke("echo", new Object[] { new Element("hi") });
}