ServiceEndpoint se = container.getRegistry().getEndpointsForService(service)[0];
Document doc = container.getRegistry().getEndpointDescriptor(se);
String wsdl = new SourceTransformer().toString(doc);
log.info(wsdl);
DefaultServiceMixClient client = new DefaultServiceMixClient(container);
Destination dest = client.createDestination("service:http://jsr181.servicemix.apache.org/EchoWithAttachment");
InOut me = dest.createInOutExchange();
me.getInMessage().setContent(new StringSource(
"<echo xmlns:xop='http://www.w3.org/2004/08/xop/include'><msg>"
+ "hello world</msg><binary><xop:Include href='binary'/></binary></echo>"));
me.getInMessage().addAttachment("binary", new DataHandler(
new ByteArrayDataSource(new byte[] {0, 1, 2}, "image/jpg")));
client.sendSync(me);
assertNotNull(me.getOutMessage());
assertEquals(1, me.getOutMessage().getAttachmentNames().size());
DataHandler dh = me.getOutMessage().getAttachment(
(String) me.getOutMessage().getAttachmentNames().iterator().next());
assertNotNull(dh);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileUtil.copyInputStream(dh.getInputStream(), baos);
assertEquals(3, baos.toByteArray().length);
client.done(me);
}