You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by tog <gu...@gmail.com> on 2007/09/05 17:35:19 UTC

newbie to MTOM with Aegis

Hiya

I tried to enabled MTOM using Aegis binding. I have a method having this
signature ...
  byte[] getFile(String name)

Accordingly to the doc, I added:

       sf = new ServerFactoryBean();

        Map<String,Object> props = new HashMap<String, Object>();
        props.put("mtom-enabled", Boolean.TRUE);
        sf.setProperties(props);

to enable MTOM.

Looking at the generated WSDL, I got:

<xsd:complexType name="getFileResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="return" type="xsd:base64Binary"/>
</xsd:sequence>
</xsd:complexType>

Is that correct. I thought I should get an
  xmime:expectedContentTypes="application/octet-stream"  ?

An other question, I am also using the dynamic client, is there a way to
enable MTOM on this side ?

Thanks



-- 

Best Regards
Guillaume

Re: newbie to MTOM with Aegis

Posted by Freeman Fang <fr...@iona.com>.
Hi Guillaume,

Is it possible that you send me your project working copy? It would be 
easier for me to debug and test it.
Best Regards

Freeman


tog wrote:
> Freeman,
>
> Thanks, I now get into the right method but get an another weird exception
> that I did not get time yet to explore deeper.
>
> 10 sept. 2007 08:20:21
> org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
> INFO: Outbound Message
> --------------------------------------
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body
> /></soap:Envelope>
> --------------------------------------
> 10 sept. 2007 08:20:21
> org.apache.cxf.interceptor.LoggingInInterceptorhandleMessage
> INFO: Inbound Message
> --------------------------------------
> Headers: {null=[HTTP/1.1 200 OK], transfer-encoding=[chunked],
> Server=[Jetty(6.1.x)]}
> Message:
>
> --------------------------------------
> 10 sept. 2007 08:20:21 org.apache.cxf.phase.PhaseInterceptorChaindoIntercept
> INFO: Interceptor has thrown exception, unwinding now
>
>
>
>
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
>         at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> (ReadHeadersInterceptor.java:189)
>         at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
> (ReadHeadersInterceptor.java:57)
>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:207)
>         at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:395)
>         at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse
> (HTTPConduit.java:1932)
>         at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
> HTTPConduit.java:1790)
>         at org.apache.cxf.transport.AbstractConduit.close(
> AbstractConduit.java:66)
>         at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java
> :576)
>         at
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
> (MessageSenderInterceptor.java:62)
>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:207)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
>         at groovyx.net.ws.WSClient.invokeMethod(WSClient.java:50)
>
>
> On 9/10/07, Freeman Fang <fr...@iona.com> wrote:
>   
>> Hi Guillaume,
>>
>> Try to use
>> Object[] response = client.invoke(op, (Object[])objs, context)
>> but not
>> client.invoke(op, (Object[])objs, context, null)
>> Since in Client.java, there is no api for client.invoke(op,
>> (Object[])objs, context, null), so if you use client.invoke(op,
>> (Object[])objs, context, null), it would be delegate to invoke(boi,
>> Object ...)
>> But if you use client.invoke(op, (Object[])objs, context), it would be
>> delegate to invoke(BindingOperationInfo oi,
>>                     Object[] params,
>>                     Map<String, Object> context)
>> You can see in JaxWsClientTest.java, line 137
>> Object ret[] = client.invoke(bop, new Object[] {"hi"}, null);
>> It is run into  invoke(BindingOperationInfo oi,
>>                     Object[] params,
>>                     Map<String, Object> context) but not
>> invoke(BindingOperationInfo oi,
>>                     Object... params)
>> if you debug in.
>>
>>
>> Best Regards
>>
>> Freeman
>>
>> tog wrote:
>>     
>>> Hi Freeman,
>>>
>>>
>>>
>>>       
>>>> The stacktrace shows Object[] invoke(BindingOperationInfo oi, Object...
>>>> params) is invoked, but not the
>>>> Object[] invoke(BindingOperationInfo oi,
>>>>                            Object[] params,
>>>>                            Map<String, Object> context,
>>>>                            Exchange exchange)
>>>> as we want. Would you please check your goovy rumtime invoker to make
>>>> sure it just pass in all paras to cxf ClientImpl?
>>>>
>>>> The call is made in Java ... and here is the invoker:
>>>>
>>>>         
>>>     public Object invokeMethod(String name, Object args) {
>>>         Object[] objs = InvokerHelper.getInstance().asArray(args);
>>>
>>>         try {
>>>
>>>             QName qname = new
>>> QName(client.getEndpoint().getService().getName().getNamespaceURI(),
>>> name);
>>>             BindingOperationInfo op = client.getEndpoint
>>> ().getEndpointInfo().getBinding().getOperation(qname);
>>>
>>>             System.out.println("-> " + qname.toString() + "  -  " +
>>> op.toString());
>>>
>>>             Object[] response = client.invoke(op, (Object[])objs,
>>>       
>> context,
>>     
>>> null);
>>>
>>> ...
>>>
>>> As you can see I do invoke the 4 args methods ... ?
>>>
>>> How can it make the difference between:
>>>
>>>   invoke(boi, Object ...)  and invoke(boi, Object[], Map, Exchange)
>>>       
>> these
>>     
>>> are all objects. Isn't  it ?
>>>
>>> Regards
>>> Guillaume
>>>
>>>
>>>       
>
>
>
>   

Re: newbie to MTOM with Aegis

Posted by tog <gu...@gmail.com>.
Freeman,

Thanks, I now get into the right method but get an another weird exception
that I did not get time yet to explore deeper.

10 sept. 2007 08:20:21
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
--------------------------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body
/></soap:Envelope>
--------------------------------------
10 sept. 2007 08:20:21
org.apache.cxf.interceptor.LoggingInInterceptorhandleMessage
INFO: Inbound Message
--------------------------------------
Headers: {null=[HTTP/1.1 200 OK], transfer-encoding=[chunked],
Server=[Jetty(6.1.x)]}
Message:

--------------------------------------
10 sept. 2007 08:20:21 org.apache.cxf.phase.PhaseInterceptorChaindoIntercept
INFO: Interceptor has thrown exception, unwinding now




INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
        at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
(ReadHeadersInterceptor.java:189)
        at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage
(ReadHeadersInterceptor.java:57)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:207)
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:395)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse
(HTTPConduit.java:1932)
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
HTTPConduit.java:1790)
        at org.apache.cxf.transport.AbstractConduit.close(
AbstractConduit.java:66)
        at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java
:576)
        at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
(MessageSenderInterceptor.java:62)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:207)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
        at groovyx.net.ws.WSClient.invokeMethod(WSClient.java:50)


On 9/10/07, Freeman Fang <fr...@iona.com> wrote:
>
> Hi Guillaume,
>
> Try to use
> Object[] response = client.invoke(op, (Object[])objs, context)
> but not
> client.invoke(op, (Object[])objs, context, null)
> Since in Client.java, there is no api for client.invoke(op,
> (Object[])objs, context, null), so if you use client.invoke(op,
> (Object[])objs, context, null), it would be delegate to invoke(boi,
> Object ...)
> But if you use client.invoke(op, (Object[])objs, context), it would be
> delegate to invoke(BindingOperationInfo oi,
>                     Object[] params,
>                     Map<String, Object> context)
> You can see in JaxWsClientTest.java, line 137
> Object ret[] = client.invoke(bop, new Object[] {"hi"}, null);
> It is run into  invoke(BindingOperationInfo oi,
>                     Object[] params,
>                     Map<String, Object> context) but not
> invoke(BindingOperationInfo oi,
>                     Object... params)
> if you debug in.
>
>
> Best Regards
>
> Freeman
>
> tog wrote:
> > Hi Freeman,
> >
> >
> >
> >> The stacktrace shows Object[] invoke(BindingOperationInfo oi, Object...
> >> params) is invoked, but not the
> >> Object[] invoke(BindingOperationInfo oi,
> >>                            Object[] params,
> >>                            Map<String, Object> context,
> >>                            Exchange exchange)
> >> as we want. Would you please check your goovy rumtime invoker to make
> >> sure it just pass in all paras to cxf ClientImpl?
> >>
> >> The call is made in Java ... and here is the invoker:
> >>
> >
> >     public Object invokeMethod(String name, Object args) {
> >         Object[] objs = InvokerHelper.getInstance().asArray(args);
> >
> >         try {
> >
> >             QName qname = new
> > QName(client.getEndpoint().getService().getName().getNamespaceURI(),
> > name);
> >             BindingOperationInfo op = client.getEndpoint
> > ().getEndpointInfo().getBinding().getOperation(qname);
> >
> >             System.out.println("-> " + qname.toString() + "  -  " +
> > op.toString());
> >
> >             Object[] response = client.invoke(op, (Object[])objs,
> context,
> > null);
> >
> > ...
> >
> > As you can see I do invoke the 4 args methods ... ?
> >
> > How can it make the difference between:
> >
> >   invoke(boi, Object ...)  and invoke(boi, Object[], Map, Exchange)
> these
> > are all objects. Isn't  it ?
> >
> > Regards
> > Guillaume
> >
> >
>



-- 

Best Regards
Guillaume
http://cheztog.blogspot.com

Re: newbie to MTOM with Aegis

Posted by Freeman Fang <fr...@iona.com>.
Hi Guillaume,

Try to use
Object[] response = client.invoke(op, (Object[])objs, context)
but not
client.invoke(op, (Object[])objs, context, null)
Since in Client.java, there is no api for client.invoke(op, 
(Object[])objs, context, null), so if you use client.invoke(op, 
(Object[])objs, context, null), it would be delegate to invoke(boi, 
Object ...)
But if you use client.invoke(op, (Object[])objs, context), it would be 
delegate to invoke(BindingOperationInfo oi,
                    Object[] params,
                    Map<String, Object> context)
You can see in JaxWsClientTest.java, line 137
Object ret[] = client.invoke(bop, new Object[] {"hi"}, null);
It is run into  invoke(BindingOperationInfo oi,
                    Object[] params,
                    Map<String, Object> context) but not
invoke(BindingOperationInfo oi,
                    Object... params)
if you debug in.


Best Regards

Freeman

tog wrote:
> Hi Freeman,
>
>
>   
>> The stacktrace shows Object[] invoke(BindingOperationInfo oi, Object...
>> params) is invoked, but not the
>> Object[] invoke(BindingOperationInfo oi,
>>                            Object[] params,
>>                            Map<String, Object> context,
>>                            Exchange exchange)
>> as we want. Would you please check your goovy rumtime invoker to make
>> sure it just pass in all paras to cxf ClientImpl?
>>
>> The call is made in Java ... and here is the invoker:
>>     
>
>     public Object invokeMethod(String name, Object args) {
>         Object[] objs = InvokerHelper.getInstance().asArray(args);
>
>         try {
>
>             QName qname = new
> QName(client.getEndpoint().getService().getName().getNamespaceURI(),
> name);
>             BindingOperationInfo op = client.getEndpoint
> ().getEndpointInfo().getBinding().getOperation(qname);
>
>             System.out.println("-> " + qname.toString() + "  -  " +
> op.toString());
>
>             Object[] response = client.invoke(op, (Object[])objs, context,
> null);
>
> ...
>
> As you can see I do invoke the 4 args methods ... ?
>
> How can it make the difference between:
>
>   invoke(boi, Object ...)  and invoke(boi, Object[], Map, Exchange) these
> are all objects. Isn't  it ?
>
> Regards
> Guillaume
>
>   

Re: newbie to MTOM with Aegis

Posted by tog <gu...@gmail.com>.
Hi Freeman,


> >
> The stacktrace shows Object[] invoke(BindingOperationInfo oi, Object...
> params) is invoked, but not the
> Object[] invoke(BindingOperationInfo oi,
>                            Object[] params,
>                            Map<String, Object> context,
>                            Exchange exchange)
> as we want. Would you please check your goovy rumtime invoker to make
> sure it just pass in all paras to cxf ClientImpl?
>
> The call is made in Java ... and here is the invoker:

    public Object invokeMethod(String name, Object args) {
        Object[] objs = InvokerHelper.getInstance().asArray(args);

        try {

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

            System.out.println("-> " + qname.toString() + "  -  " +
op.toString());

            Object[] response = client.invoke(op, (Object[])objs, context,
null);

...

As you can see I do invoke the 4 args methods ... ?

How can it make the difference between:

  invoke(boi, Object ...)  and invoke(boi, Object[], Map, Exchange) these
are all objects. Isn't  it ?

Regards
Guillaume

Re: newbie to MTOM with Aegis

Posted by Freeman Fang <fr...@iona.com>.
Comment inline
tog wrote:
> Thanks freeman for the answer,
>
>
>   
>> You can do it with jaxb databing which is little tricky,  by means of
>> adding jaxb annotation @XmlMimeType("application/octet-stream") on
>> DataHandler
>> you can get more details from
>>
>> http://www.nabble.com/MTOM-sample-generated-WSDL-with-DataHandler-on-server-t4210895.html
>>     
>
>
> Ok, I read that thread. So does this mean that on the client side I will
> have to deal with a byte[] when specifying a DataHandler on the server side
> ?
> Since I am using groovy, I don't forge any wsdl.
>   
If you are using aegis databinding,  the answer is yes. So I believe you 
need use byte[] to define paras or return which you want to pass using 
mtom  .
If you use jaxb databinding, you can use "wrapper" classes to get it 
around, which means the generated wsdl include 
xmime:expectedContentTypes="application/octet-stream", and the dynamic 
client you generate from the wsdl has the DataHandler para type
The wrapper class looks like

@XmlType
public class Picture {
  private String title;

  @XmlMimeType("application/octet-stream")
  private DataHandler imageData;

  public String getTitle() { return title; }
  public void setTitle(String title) { this.title = title; }

  public DataHandler getImageData() { return imageData; }
  public void setImageData(DataHandler imageData) { this.imageData = imageData; }
}


>                     // create client from DynamicClientFactory and then
>   
>> use client api which can pass in context
>>                    client.invoke(BindingOperationInfo oi, Object[]
>> params, Map<String, Object> context)
>>
>> You can see how to get BindingOperationInfo from operationName in
>> org.apache.cxf.endpoint.ClientImpl.
>>     
>
>
> I was using invoke(String, Object[])
>
> I changed that to
>
>             QName qname = new
> QName(client.getEndpoint().getService().getName().getNamespaceURI(),
> name);
>             BindingOperationInfo op = client.getEndpoint
> ().getEndpointInfo().getBinding().getOperation(qname);
>
>             Object[] response = client.invoke(op, objs, context, null);
>
> Is that what you meant ?
>   
Yes
> Can the context be set MTOM to true, even if I don't need it for the
> operation. This will be very difficult for me to determine which operation
> need MTOM and which don't ?
>
>   
I think the answer is yes and no.
Basiclaly, what mtom do is just "optimizes" any base64Binary data you 
have in your messages. When MTOM is turned on, this base64 data gets 
sent as a binary attachment saving time and space.

Scenario when the answer is no
If the operation indeed don't need mtom  enabled and has base64Binary 
data in the message body, turn on mtom will cause it fail to invoke the 
server.

Scenario when the answer is yes
The message body for such operation has no base64Binary data, turn on or 
off the mtom enable will not change the message, so it should be ok.

You can get more idea from the thread "MTOM "By Request"" of mailing 
list about auto-aware mtom enabled, we support it on server side but not 
on client side IMHO.
> If yes, I now get that exception. It looks I am calling:
>
>                public Object[] invoke(String operationName, Object...
> params)
>
> rather than:
>
>                   public Object[] invoke(BindingOperationInfo oi,
>                            Object[] params,
>                            Map<String, Object> context,
>                            Exchange exchange)
>
> Thoughts ?
>
> Regards
> Guillaume
>
>
>   
The stacktrace shows Object[] invoke(BindingOperationInfo oi, Object... 
params) is invoked, but not the
Object[] invoke(BindingOperationInfo oi,
                           Object[] params,
                           Map<String, Object> context,
                           Exchange exchange)
as we want. Would you please check your goovy rumtime invoker to make 
sure it just pass in all paras to cxf ClientImpl?
Best Regards

Freeman

> alleon@oggy:~/.eclipse/workspace/groovyws/src/test/test1/client$ groovy
> client.groovy
> Found JAXB 2.1
> 7 sept. 2007 08:56:13
> org.apache.cxf.endpoint.dynamic.DynamicClientFactoryaddSchemas
> INFO: Loading the JAXB 2.1 simple binding for client.
> 7 sept. 2007 08:56:14
> org.apache.cxf.endpoint.dynamic.DynamicClientFactoryoutputDebug
> INFO: Created classes: com.acme.type.ArrayOfBook, com.acme.type.Book,
> com.acme.type.ObjectFactory, defaultnamespace.AddBook,
> defaultnamespace.AddBookResponse, defaultnamespace.FindBook,
> defaultnamespace.FindBookResponse, defaultnamespace.GetBooks,
> defaultnamespace.GetBooksResponse, defaultnamespace.ObjectFactory
> 7 sept. 2007 08:56:16 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Marshalling Error: [Ljava.lang.Object; is
> not known to this context
>         at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(
> JAXBEncoderDecoder.java:179)
>         at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java
> :42)
>         at
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(
> AbstractOutDatabindingInterceptor.java:84)
>         at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(
> BareOutInterceptor.java:68)
>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
> PhaseInterceptorChain.java:207)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:180)
>         at groovyx.net.ws.WSClient.invokeMethod(WSClient.java:48)
>         at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java
> :119)
>         at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:81)
>         at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(
> InvokerHelper.java:85)
>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(
> ScriptBytecodeAdapter.java:158)
>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(
> ScriptBytecodeAdapter.java:182)
>         at client.run(client.groovy:5)
>
>
>
>
>
> Freeman
>   
>> tog wrote:
>>     
>>> Hiya
>>>
>>> I tried to enabled MTOM using Aegis binding. I have a method having this
>>> signature ...
>>>   byte[] getFile(String name)
>>>
>>> Accordingly to the doc, I added:
>>>
>>>        sf = new ServerFactoryBean();
>>>
>>>         Map<String,Object> props = new HashMap<String, Object>();
>>>         props.put("mtom-enabled", Boolean.TRUE);
>>>         sf.setProperties(props);
>>>
>>> to enable MTOM.
>>>
>>> Looking at the generated WSDL, I got:
>>>
>>> <xsd:complexType name="getFileResponse">
>>> <xsd:sequence>
>>> <xsd:element minOccurs="0" name="return" type="xsd:base64Binary"/>
>>> </xsd:sequence>
>>> </xsd:complexType>
>>>
>>> Is that correct. I thought I should get an
>>>   xmime:expectedContentTypes="application/octet-stream"  ?
>>>
>>> An other question, I am also using the dynamic client, is there a way to
>>> enable MTOM on this side ?
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>       
>
>
>
>   

Re: newbie to MTOM with Aegis

Posted by tog <gu...@gmail.com>.
Thanks freeman for the answer,


> You can do it with jaxb databing which is little tricky,  by means of
> adding jaxb annotation @XmlMimeType("application/octet-stream") on
> DataHandler
> you can get more details from
>
> http://www.nabble.com/MTOM-sample-generated-WSDL-with-DataHandler-on-server-t4210895.html


Ok, I read that thread. So does this mean that on the client side I will
have to deal with a byte[] when specifying a DataHandler on the server side
?
Since I am using groovy, I don't forge any wsdl.

                    // create client from DynamicClientFactory and then
> use client api which can pass in context
>                    client.invoke(BindingOperationInfo oi, Object[]
> params, Map<String, Object> context)
>
> You can see how to get BindingOperationInfo from operationName in
> org.apache.cxf.endpoint.ClientImpl.


I was using invoke(String, Object[])

I changed that to

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

            Object[] response = client.invoke(op, objs, context, null);

Is that what you meant ?

Can the context be set MTOM to true, even if I don't need it for the
operation. This will be very difficult for me to determine which operation
need MTOM and which don't ?

If yes, I now get that exception. It looks I am calling:

               public Object[] invoke(String operationName, Object...
params)

rather than:

                  public Object[] invoke(BindingOperationInfo oi,
                           Object[] params,
                           Map<String, Object> context,
                           Exchange exchange)

Thoughts ?

Regards
Guillaume


alleon@oggy:~/.eclipse/workspace/groovyws/src/test/test1/client$ groovy
client.groovy
Found JAXB 2.1
7 sept. 2007 08:56:13
org.apache.cxf.endpoint.dynamic.DynamicClientFactoryaddSchemas
INFO: Loading the JAXB 2.1 simple binding for client.
7 sept. 2007 08:56:14
org.apache.cxf.endpoint.dynamic.DynamicClientFactoryoutputDebug
INFO: Created classes: com.acme.type.ArrayOfBook, com.acme.type.Book,
com.acme.type.ObjectFactory, defaultnamespace.AddBook,
defaultnamespace.AddBookResponse, defaultnamespace.FindBook,
defaultnamespace.FindBookResponse, defaultnamespace.GetBooks,
defaultnamespace.GetBooksResponse, defaultnamespace.ObjectFactory
7 sept. 2007 08:56:16 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: [Ljava.lang.Object; is
not known to this context
        at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(
JAXBEncoderDecoder.java:179)
        at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java
:42)
        at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(
AbstractOutDatabindingInterceptor.java:84)
        at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(
BareOutInterceptor.java:68)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
PhaseInterceptorChain.java:207)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:180)
        at groovyx.net.ws.WSClient.invokeMethod(WSClient.java:48)
        at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java
:119)
        at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:81)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(
InvokerHelper.java:85)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(
ScriptBytecodeAdapter.java:158)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(
ScriptBytecodeAdapter.java:182)
        at client.run(client.groovy:5)





Freeman
>
> tog wrote:
> > Hiya
> >
> > I tried to enabled MTOM using Aegis binding. I have a method having this
> > signature ...
> >   byte[] getFile(String name)
> >
> > Accordingly to the doc, I added:
> >
> >        sf = new ServerFactoryBean();
> >
> >         Map<String,Object> props = new HashMap<String, Object>();
> >         props.put("mtom-enabled", Boolean.TRUE);
> >         sf.setProperties(props);
> >
> > to enable MTOM.
> >
> > Looking at the generated WSDL, I got:
> >
> > <xsd:complexType name="getFileResponse">
> > <xsd:sequence>
> > <xsd:element minOccurs="0" name="return" type="xsd:base64Binary"/>
> > </xsd:sequence>
> > </xsd:complexType>
> >
> > Is that correct. I thought I should get an
> >   xmime:expectedContentTypes="application/octet-stream"  ?
> >
> > An other question, I am also using the dynamic client, is there a way to
> > enable MTOM on this side ?
> >
> > Thanks
> >
> >
> >
> >
>



-- 

Best Regards
Guillaume
http://cheztog.blogspot.com

Re: newbie to MTOM with Aegis

Posted by Freeman Fang <fr...@iona.com>.
Hi Guillaume,

For your first question, it is correct when you use aegis databinding.
You can't generate wsdl having 
xmime:expectedContentTypes="application/octet-stream" with aegis 
databinding.

You can do it with jaxb databing which is little tricky,  by means of 
adding jaxb annotation @XmlMimeType("application/octet-stream") on 
DataHandler
you can get more details from
http://www.nabble.com/MTOM-sample-generated-WSDL-with-DataHandler-on-server-t4210895.html 


For your second question, you can do it like

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

                    // create client from DynamicClientFactory and then 
use client api which can pass in context
                   client.invoke(BindingOperationInfo oi, Object[] 
params, Map<String, Object> context)

You can see how to get BindingOperationInfo from operationName in 
org.apache.cxf.endpoint.ClientImpl.
Best Regards

Freeman

tog wrote:
> Hiya
>
> I tried to enabled MTOM using Aegis binding. I have a method having this
> signature ...
>   byte[] getFile(String name)
>
> Accordingly to the doc, I added:
>
>        sf = new ServerFactoryBean();
>
>         Map<String,Object> props = new HashMap<String, Object>();
>         props.put("mtom-enabled", Boolean.TRUE);
>         sf.setProperties(props);
>
> to enable MTOM.
>
> Looking at the generated WSDL, I got:
>
> <xsd:complexType name="getFileResponse">
> <xsd:sequence>
> <xsd:element minOccurs="0" name="return" type="xsd:base64Binary"/>
> </xsd:sequence>
> </xsd:complexType>
>
> Is that correct. I thought I should get an
>   xmime:expectedContentTypes="application/octet-stream"  ?
>
> An other question, I am also using the dynamic client, is there a way to
> enable MTOM on this side ?
>
> Thanks
>
>
>
>