You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by petrica <pe...@cluemail.com> on 2007/08/06 08:02:48 UTC

CXF server with XFire generated client - problem with returning a type DataHandler with MTOM

Hi all,

I have a CXF server and generate automatically a XFire client. 
I used mtom sample from CXF distribution and testMtom function that
marshall/unmarshall a DataHandler INOUT parameter. The client will send OK a
file as an attachment through DataHandler parameter to server , but it seems
the server cannot send another file back to client. 
In example below, the file <server.zip> from testMtom server function does
not arrive on client side.

1. I activated in client and server optiopns for MTOM ( <mtom.enabled >) 
    In client ->  client.setProperty("mtom-enabled", "true"); 
    In server -> <jaxws:properties> <entry key="mtom-enabled" value="true"/>
.....

2. Alocate an instance of DataHandler on client :

        Holder<DataHandler> handler = new Holder<DataHandler>();
        byte[] data = new byte[(int) fileSize];
        new FileInputStream("c:\\temp\\client.zip").read(data);
        handler.value = new DataHandler(new ByteArrayDataSource(data,
"application/octet-stream"));

        MtomType xpMtom = new MtomType();
        xpMtom.setAttachinfo( handler.value );
        service.testMtom( xpMtom );

3.  On server :
      void testMtom( Holder<DataHandler> attachinfo)  { 
            InputStream mtomIn = attachinfo.value.getInputStream();
            long fileSize = 0;            
            for (int i = mtomIn.read(); i != -1; i = mtomIn.read()) {
                fileSize++;
            }            
            System.out.println("The image holder data length is " +
mtomIn.available());

            attachinfo.value = new DataHandler( new
FileDataSource("c:\\temp\\server.zip") );
     }
   
Where is the mistake ? 

Can anybody give me an advice

Any help is appreciated,
Petrica   
-- 
View this message in context: http://www.nabble.com/CXF-server-with-XFire-generated-client---problem-with-returning-a-type-DataHandler-with-MTOM-tf4222406.html#a12011445
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF server with XFire generated client - problem with returning a type DataHandler with MTOM

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 07 August 2007 18:56, mark.boyd wrote:
> From another thread on this list it appears that the jaxws:features
> tag must be nested within the jaxws:endpoint tag.

Oops.   Yep.  Sorry for not being more clear on that.   That's correct.  
You are applying that feature to that endpoint.

Dan


>
> Mark
>
>
>
> Dan,
>
> Can you shed light on the jaxws:feature tag. I tried this and I get:
>
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
> Line 37 in XML document from ServletContext resource
> [/WEB-INF/beans.xml] is invalid; nested except
> ion is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The
> matching wildcard is strict, but no declaration can be found for
> element 'jaxws:features'.
> Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The
> matching wildcard is strict, but no declaration can be found for
> element 'jaxws:features'.
>
> I looked at the spring.handlers in cxf-2.0-incubator.jar and the
> registered handler class is
> org.apache.cxf.jaxws.spring.NamespaceHandler which only registers
> handlers for endpoint, client, and server. So is jaxws:feature a new
> feature on the way that isn't in 2.0 as yet?
>
> Thanks.
>
> Mark
>
> dkulp wrote:
> > ...
> > 3) Any chance of getting a tcpdump of the response?   I'd like to
> > know if the data is on the wire or not.   Since you seem to be using
> > spring config on the server, you could just try adding:
> > <jaxws:features>
> >      <bean class="org.apache.cxf.feature.LoggingFeature"/>
> > </jaxws:features>
> > and looking at the log output.

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: CXF server with XFire generated client - problem with returning a type DataHandler with MTOM

Posted by "mark.boyd" <bo...@ldschurch.org>.
>From another thread on this list it appears that the jaxws:features tag must
be nested within the jaxws:endpoint tag.

Mark



Dan,

Can you shed light on the jaxws:feature tag. I tried this and I get:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line
37 in XML document from ServletContext resource [/WEB-INF/beans.xml] is
invalid; nested except
ion is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching
wildcard is strict, but no declaration can be found for element
'jaxws:features'.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The
matching wildcard is strict, but no declaration can be found for element
'jaxws:features'.

I looked at the spring.handlers in cxf-2.0-incubator.jar and the registered
handler class is org.apache.cxf.jaxws.spring.NamespaceHandler which only
registers handlers for endpoint, client, and server. So is jaxws:feature a
new feature on the way that isn't in 2.0 as yet?

Thanks.

Mark



dkulp wrote:
> 
> ...
> 3) Any chance of getting a tcpdump of the response?   I'd like to know if 
> the data is on the wire or not.   Since you seem to be using spring 
> config on the server, you could just try adding:
> <jaxws:features>
>      <bean class="org.apache.cxf.feature.LoggingFeature"/>
> </jaxws:features>
> and looking at the log output.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/CXF-server-with-XFire-generated-client---problem-with-returning-a-type-DataHandler-with-MTOM-tf4222406.html#a12044166
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF server with XFire generated client - problem with returning a type DataHandler with MTOM

Posted by "mark.boyd" <bo...@ldschurch.org>.
Dan,

Can you shed light on the jaxws:feature tag. I tried this and I get:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line
37 in XML document from ServletContext resource [/WEB-INF/beans.xml] is
invalid; nested except
ion is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching
wildcard is strict, but no declaration can be found for element
'jaxws:features'.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The
matching wildcard is strict, but no declaration can be found for element
'jaxws:features'.

I looked at the spring.handlers in cxf-2.0-incubator.jar and the registered
handler class is org.apache.cxf.jaxws.spring.NamespaceHandler which only
registers handlers for endpoint, client, and server. So is jaxws:feature a
new feature on the way that isn't in 2.0 as yet?

Thanks.

Mark



...
3) Any chance of getting a tcpdump of the response?   I'd like to know if 
the data is on the wire or not.   Since you seem to be using spring 
config on the server, you could just try adding:
<jaxws:features>
     <bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
and looking at the log output.


-- 
View this message in context: http://www.nabble.com/CXF-server-with-XFire-generated-client---problem-with-returning-a-type-DataHandler-with-MTOM-tf4222406.html#a12043857
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF server with XFire generated client - problem with returning a type DataHandler with MTOM

Posted by petrica <pe...@cluemail.com>.
Hi,

It's works with XFire generated client ( not the same client from Mtom
sample) .
I used both Tomcat 5.5 and Geronimo 1.1 on Windows. The client was in
intranet behind a firewall and server is in Internet with Apache Geronimo. 

It was my fault. I had reading an InputStream twice ( first for size ). 
I used XFire client and not CXF client because I didn't find out how to pass
a proxy username and password in CXF client ( it is another question of mine
on forum with no reply ).

Finally I built a complex application( without lists of objects) but I
limited only ( for moment of course ) for simple data type in
marshalling/unmarshalling that works without problems through corporate
proxy servers.

Thanks Dan


dkulp wrote:
> 
> On Monday 06 August 2007 02:02, petrica wrote:
>> I have a CXF server and generate automatically a XFire client.
>> I used mtom sample from CXF distribution and testMtom function that
>> marshall/unmarshall a DataHandler INOUT parameter. The client will
>> send OK a file as an attachment through DataHandler parameter to
>> server , but it seems the server cannot send another file back to
>> client.
>> In example below, the file <server.zip> from testMtom server function
>> does not arrive on client side.
> 
> The code looks OK to me.   Couple of questions:
> 1) Does the client spit out any error or does it just return no data?
> 
> 2) Is  the server running in tomcat or is this a standalone?    We 
> discovered a bug in tomcat where the mtom headers were getting messed 
> up.   We've worked around the tomcat bug in the latest trunk code.
> 
> 3) Any chance of getting a tcpdump of the response?   I'd like to know if 
> the data is on the wire or not.   Since you seem to be using spring 
> config on the server, you could just try adding:
> <jaxws:features>
>      <bean class="org.apache.cxf.feature.LoggingFeature"/>
> </jaxws:features>
> and looking at the log output.
> 
> 4) You could also try something similar to what you are doing on the 
> client side: create a ByteArrayDataSource and use a DataHandler  
> wrapping that.   It's POSSIBLE that something isn't working with the 
> FileDataSource. 
> 
> Dan
> 
> 
>>
>> 1. I activated in client and server optiopns for MTOM ( <mtom.enabled
>> >) In client ->  client.setProperty("mtom-enabled", "true"); In server
>> -> <jaxws:properties> <entry key="mtom-enabled" value="true"/> .....
>>
>> 2. Alocate an instance of DataHandler on client :
>>
>>         Holder<DataHandler> handler = new Holder<DataHandler>();
>>         byte[] data = new byte[(int) fileSize];
>>         new FileInputStream("c:\\temp\\client.zip").read(data);
>>         handler.value = new DataHandler(new ByteArrayDataSource(data,
>> "application/octet-stream"));
>>
>>         MtomType xpMtom = new MtomType();
>>         xpMtom.setAttachinfo( handler.value );
>>         service.testMtom( xpMtom );
>>
>> 3.  On server :
>>       void testMtom( Holder<DataHandler> attachinfo)  {
>>             InputStream mtomIn = attachinfo.value.getInputStream();
>>             long fileSize = 0;
>>             for (int i = mtomIn.read(); i != -1; i = mtomIn.read()) {
>>                 fileSize++;
>>             }
>>             System.out.println("The image holder data length is " +
>> mtomIn.available());
>>
>>             attachinfo.value = new DataHandler( new
>> FileDataSource("c:\\temp\\server.zip") );
>>      }
>>
>> Where is the mistake ?
>>
>> Can anybody give me an advice
>>
>> Any help is appreciated,
>> Petrica
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/CXF-server-with-XFire-generated-client---problem-with-returning-a-type-DataHandler-with-MTOM-tf4222406.html#a12033569
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF server with XFire generated client - problem with returning a type DataHandler with MTOM

Posted by Daniel Kulp <dk...@apache.org>.
On Monday 06 August 2007 02:02, petrica wrote:
> I have a CXF server and generate automatically a XFire client.
> I used mtom sample from CXF distribution and testMtom function that
> marshall/unmarshall a DataHandler INOUT parameter. The client will
> send OK a file as an attachment through DataHandler parameter to
> server , but it seems the server cannot send another file back to
> client.
> In example below, the file <server.zip> from testMtom server function
> does not arrive on client side.

The code looks OK to me.   Couple of questions:
1) Does the client spit out any error or does it just return no data?

2) Is  the server running in tomcat or is this a standalone?    We 
discovered a bug in tomcat where the mtom headers were getting messed 
up.   We've worked around the tomcat bug in the latest trunk code.

3) Any chance of getting a tcpdump of the response?   I'd like to know if 
the data is on the wire or not.   Since you seem to be using spring 
config on the server, you could just try adding:
<jaxws:features>
     <bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
and looking at the log output.

4) You could also try something similar to what you are doing on the 
client side: create a ByteArrayDataSource and use a DataHandler  
wrapping that.   It's POSSIBLE that something isn't working with the 
FileDataSource. 

Dan


>
> 1. I activated in client and server optiopns for MTOM ( <mtom.enabled
> >) In client ->  client.setProperty("mtom-enabled", "true"); In server
> -> <jaxws:properties> <entry key="mtom-enabled" value="true"/> .....
>
> 2. Alocate an instance of DataHandler on client :
>
>         Holder<DataHandler> handler = new Holder<DataHandler>();
>         byte[] data = new byte[(int) fileSize];
>         new FileInputStream("c:\\temp\\client.zip").read(data);
>         handler.value = new DataHandler(new ByteArrayDataSource(data,
> "application/octet-stream"));
>
>         MtomType xpMtom = new MtomType();
>         xpMtom.setAttachinfo( handler.value );
>         service.testMtom( xpMtom );
>
> 3.  On server :
>       void testMtom( Holder<DataHandler> attachinfo)  {
>             InputStream mtomIn = attachinfo.value.getInputStream();
>             long fileSize = 0;
>             for (int i = mtomIn.read(); i != -1; i = mtomIn.read()) {
>                 fileSize++;
>             }
>             System.out.println("The image holder data length is " +
> mtomIn.available());
>
>             attachinfo.value = new DataHandler( new
> FileDataSource("c:\\temp\\server.zip") );
>      }
>
> Where is the mistake ?
>
> Can anybody give me an advice
>
> Any help is appreciated,
> Petrica

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog