You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Basile Clout <ic...@gmail.com> on 2008/11/05 14:29:16 UTC

Mtom attachment with Aegis databinding for a DynamicClientFactory client

Hi all,

I'm trying to implement a web service that needs to be able to send
and receive files with MTOM.

On the server side, I use ServerFactoryBean() with an aegis
databinding and setting MTOM with setMtomEnabled(). Sending a file
from the server to the client uses MTOM, as required.

On the client side, is there a way to enable MTOM on a
DynamicClientFactory? I cant seem to make mtom work on the client
side.

I tried to set up a context for my DynamicClientFactory client with a Map:

Map<String, Object> context = new HashMap<String, Object>();
context.put("mtom-enabled", Boolean.TRUE);
context.put("mtom-threshold", 0);

and then

QName qname = new
QName(client.getEndpoint().getService().getName().getNamespaceURI(),
name);
BindingOperationInfo op =
client.getEndpoint().getEndpointInfo().getBinding().getOperation(qname);

if (op.isUnwrappedCapable()) {
op = op.getUnwrappedOperation();
response = client.invoke(op, objs, context);
} else {
response = client.invoke(name, objs, context);
}

But sending a message from the client to the server does not use MTOM,
but the good old base64binary.
Did I miss something?

im using Apache Cxf 2.1.3 with Java5


Thanks for your help!

Re: Mtom attachment with Aegis databinding for a DynamicClientFactory client

Posted by Daniel Kulp <dk...@apache.org>.
With CXF 2.1.3, the Client interface that the DynamicClientFactory uses has 
been greatly expanded.   One of the things that was added was a request 
context.   Thus, in your case, you can do:

client.getRequestContext().put("mtom-enabled", Boolean.TRUE);

and that should do it.

Dan


On Wednesday 05 November 2008 8:29:16 am Basile Clout wrote:
> Hi all,
>
> I'm trying to implement a web service that needs to be able to send
> and receive files with MTOM.
>
> On the server side, I use ServerFactoryBean() with an aegis
> databinding and setting MTOM with setMtomEnabled(). Sending a file
> from the server to the client uses MTOM, as required.
>
> On the client side, is there a way to enable MTOM on a
> DynamicClientFactory? I cant seem to make mtom work on the client
> side.
>
> I tried to set up a context for my DynamicClientFactory client with a Map:
>
> Map<String, Object> context = new HashMap<String, Object>();
> context.put("mtom-enabled", Boolean.TRUE);
> context.put("mtom-threshold", 0);
>
> and then
>
> QName qname = new
> QName(client.getEndpoint().getService().getName().getNamespaceURI(),
> name);
> BindingOperationInfo op =
> client.getEndpoint().getEndpointInfo().getBinding().getOperation(qname);
>
> if (op.isUnwrappedCapable()) {
> op = op.getUnwrappedOperation();
> response = client.invoke(op, objs, context);
> } else {
> response = client.invoke(name, objs, context);
> }
>
> But sending a message from the client to the server does not use MTOM,
> but the good old base64binary.
> Did I miss something?
>
> im using Apache Cxf 2.1.3 with Java5
>
>
> Thanks for your help!



-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog