You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Naresh Tallapelli <na...@gmail.com> on 2010/06/10 11:53:58 UTC

How to send attachment in response to a web service call

HI All,

 I am using CXF-2.1.2 version. I have a requirement to send an attachment
from web services server to the client as part of one  web service call
response. I have created the response element as following in wsdl file,
*
<xsd:element name="fileStreamResponse" type="xsd:base64Binary"

xmime:expectedContentTypes="application/octet-stream" maxOccurs="1"
                            minOccurs="1">*

When web service operation is called i am creating "FileDataHandler" for
file and returning the handler as part of response. Server is able to send
the attachment to the client. I can see the following log message on web
services server side.

*<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns5:testMtomResponseResponse><fileStreamResponse><xop:Include
xmlns:xop="http://www.w3.org/2004/08/xop/include"
href="cid:e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%2Fcxf.apache.org
%2F"/></fileStreamResponse></ns5:testMtomResponseResponse></soap:Body></soap:Envelope>
------=_Part_0_8371737.1276162616240
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%
2Fcxf.apache.org%2F>

This is the response created intially on the server.*

But the client is not able to receive the attachment. In
"AttachmentInInterceptor" if the message type is multipart, then we cxf code
is loading the attachments lazily. That's the reason why the client is not
able to get the response. Web services client is throwing the following
exception,

*    java.io.EOFException: Unexpected end of ZLIB input stream
    at
org.apache.cxf.attachment.AttachmentDeserializer.readNext(AttachmentDeserializer.java:187)
    at
org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachmentCollection.java:73)
    at org.apache.cxf.attachment.LazyDataSource.load(LazyDataSource.java:49)
    at
org.apache.cxf.attachment.LazyDataSource.getContentType(LazyDataSource.java:59)
    at javax.activation.DataHandler.getContentType(Unknown Source)
    at javax.activation.DataHandler.getBaseType(Unknown Source)
    at javax.activation.DataHandler.getDataContentHandler(Unknown Source)
    at javax.activation.DataHandler.getContent(Unknown Source)*

Please help me to resolve this issue.Any help would be much appreciated.

Thank you,
Naresh.

Re: How to send attachment in response to a web service call

Posted by Naresh Tallapelli <na...@gmail.com>.
Thank you Daniel. It worked.

On Thu, Jun 10, 2010 at 7:53 PM, Daniel Kulp <dk...@apache.org> wrote:

>
> My suggestion would be to update to CXF 2.2.9.   There were a lot of fixes
> that were put around various streaming attachment handling that may have
> likely fixed this already.
>
> I don't know if the 2.1.10 release (last on 2.1.x) would have all the
> attachment fixes or not.
>
> Dan
>
>
>
>
> On Thursday 10 June 2010 5:53:58 am Naresh Tallapelli wrote:
> > HI All,
> >
> >  I am using CXF-2.1.2 version. I have a requirement to send an attachment
> > from web services server to the client as part of one  web service call
> > response. I have created the response element as following in wsdl file,
> > *
> > <xsd:element name="fileStreamResponse" type="xsd:base64Binary"
> >
> > xmime:expectedContentTypes="application/octet-stream" maxOccurs="1"
> >                             minOccurs="1">*
> >
> > When web service operation is called i am creating "FileDataHandler" for
> > file and returning the handler as part of response. Server is able to
> send
> > the attachment to the client. I can see the following log message on web
> > services server side.
> >
> > *<soap:Envelope
> > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/
> "><soap:Body><ns5:test
> > MtomResponseResponse><fileStreamResponse><xop:Include
> > xmlns:xop="http://www.w3.org/2004/08/xop/include"
> > href="cid:e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%
> 2Fcxf.apache.org
> >
> %2F"/></fileStreamResponse></ns5:testMtomResponseResponse></soap:Body></soa
> > p:Envelope> ------=_Part_0_8371737.1276162616240
> > Content-Type: text/plain
> > Content-Transfer-Encoding: binary
> > Content-ID: <e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%
> > 2Fcxf.apache.org%2F>
> >
> > This is the response created intially on the server.*
> >
> > But the client is not able to receive the attachment. In
> > "AttachmentInInterceptor" if the message type is multipart, then we cxf
> > code is loading the attachments lazily. That's the reason why the client
> > is not able to get the response. Web services client is throwing the
> > following exception,
> >
> > *    java.io.EOFException: Unexpected end of ZLIB input stream
> >     at
> >
> org.apache.cxf.attachment.AttachmentDeserializer.readNext(AttachmentDeseria
> > lizer.java:187) at
> >
> org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachment
> > Collection.java:73) at
> > org.apache.cxf.attachment.LazyDataSource.load(LazyDataSource.java:49) at
> >
> org.apache.cxf.attachment.LazyDataSource.getContentType(LazyDataSource.java
> > :59) at javax.activation.DataHandler.getContentType(Unknown Source) at
> > javax.activation.DataHandler.getBaseType(Unknown Source)
> >     at javax.activation.DataHandler.getDataContentHandler(Unknown Source)
> >     at javax.activation.DataHandler.getContent(Unknown Source)*
> >
> > Please help me to resolve this issue.Any help would be much appreciated.
> >
> > Thank you,
> > Naresh.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>

Re: How to send attachment in response to a web service call

Posted by Naresh Tallapelli <na...@gmail.com>.
Thank you Daniel. It worked.

On Thu, Jun 10, 2010 at 7:53 PM, Daniel Kulp <dk...@apache.org> wrote:

>
> My suggestion would be to update to CXF 2.2.9.   There were a lot of fixes
> that were put around various streaming attachment handling that may have
> likely fixed this already.
>
> I don't know if the 2.1.10 release (last on 2.1.x) would have all the
> attachment fixes or not.
>
> Dan
>
>
>
>
> On Thursday 10 June 2010 5:53:58 am Naresh Tallapelli wrote:
> > HI All,
> >
> >  I am using CXF-2.1.2 version. I have a requirement to send an attachment
> > from web services server to the client as part of one  web service call
> > response. I have created the response element as following in wsdl file,
> > *
> > <xsd:element name="fileStreamResponse" type="xsd:base64Binary"
> >
> > xmime:expectedContentTypes="application/octet-stream" maxOccurs="1"
> >                             minOccurs="1">*
> >
> > When web service operation is called i am creating "FileDataHandler" for
> > file and returning the handler as part of response. Server is able to
> send
> > the attachment to the client. I can see the following log message on web
> > services server side.
> >
> > *<soap:Envelope
> > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/
> "><soap:Body><ns5:test
> > MtomResponseResponse><fileStreamResponse><xop:Include
> > xmlns:xop="http://www.w3.org/2004/08/xop/include"
> > href="cid:e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%
> 2Fcxf.apache.org
> >
> %2F"/></fileStreamResponse></ns5:testMtomResponseResponse></soap:Body></soa
> > p:Envelope> ------=_Part_0_8371737.1276162616240
> > Content-Type: text/plain
> > Content-Transfer-Encoding: binary
> > Content-ID: <e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%
> > 2Fcxf.apache.org%2F>
> >
> > This is the response created intially on the server.*
> >
> > But the client is not able to receive the attachment. In
> > "AttachmentInInterceptor" if the message type is multipart, then we cxf
> > code is loading the attachments lazily. That's the reason why the client
> > is not able to get the response. Web services client is throwing the
> > following exception,
> >
> > *    java.io.EOFException: Unexpected end of ZLIB input stream
> >     at
> >
> org.apache.cxf.attachment.AttachmentDeserializer.readNext(AttachmentDeseria
> > lizer.java:187) at
> >
> org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachment
> > Collection.java:73) at
> > org.apache.cxf.attachment.LazyDataSource.load(LazyDataSource.java:49) at
> >
> org.apache.cxf.attachment.LazyDataSource.getContentType(LazyDataSource.java
> > :59) at javax.activation.DataHandler.getContentType(Unknown Source) at
> > javax.activation.DataHandler.getBaseType(Unknown Source)
> >     at javax.activation.DataHandler.getDataContentHandler(Unknown Source)
> >     at javax.activation.DataHandler.getContent(Unknown Source)*
> >
> > Please help me to resolve this issue.Any help would be much appreciated.
> >
> > Thank you,
> > Naresh.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>

Re: How to send attachment in response to a web service call

Posted by Daniel Kulp <dk...@apache.org>.
My suggestion would be to update to CXF 2.2.9.   There were a lot of fixes 
that were put around various streaming attachment handling that may have 
likely fixed this already. 

I don't know if the 2.1.10 release (last on 2.1.x) would have all the 
attachment fixes or not.

Dan




On Thursday 10 June 2010 5:53:58 am Naresh Tallapelli wrote:
> HI All,
> 
>  I am using CXF-2.1.2 version. I have a requirement to send an attachment
> from web services server to the client as part of one  web service call
> response. I have created the response element as following in wsdl file,
> *
> <xsd:element name="fileStreamResponse" type="xsd:base64Binary"
> 
> xmime:expectedContentTypes="application/octet-stream" maxOccurs="1"
>                             minOccurs="1">*
> 
> When web service operation is called i am creating "FileDataHandler" for
> file and returning the handler as part of response. Server is able to send
> the attachment to the client. I can see the following log message on web
> services server side.
> 
> *<soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns5:test
> MtomResponseResponse><fileStreamResponse><xop:Include
> xmlns:xop="http://www.w3.org/2004/08/xop/include"
> href="cid:e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%2Fcxf.apache.org
> %2F"/></fileStreamResponse></ns5:testMtomResponseResponse></soap:Body></soa
> p:Envelope> ------=_Part_0_8371737.1276162616240
> Content-Type: text/plain
> Content-Transfer-Encoding: binary
> Content-ID: <e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%
> 2Fcxf.apache.org%2F>
> 
> This is the response created intially on the server.*
> 
> But the client is not able to receive the attachment. In
> "AttachmentInInterceptor" if the message type is multipart, then we cxf
> code is loading the attachments lazily. That's the reason why the client
> is not able to get the response. Web services client is throwing the
> following exception,
> 
> *    java.io.EOFException: Unexpected end of ZLIB input stream
>     at
> org.apache.cxf.attachment.AttachmentDeserializer.readNext(AttachmentDeseria
> lizer.java:187) at
> org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachment
> Collection.java:73) at
> org.apache.cxf.attachment.LazyDataSource.load(LazyDataSource.java:49) at
> org.apache.cxf.attachment.LazyDataSource.getContentType(LazyDataSource.java
> :59) at javax.activation.DataHandler.getContentType(Unknown Source) at
> javax.activation.DataHandler.getBaseType(Unknown Source)
>     at javax.activation.DataHandler.getDataContentHandler(Unknown Source)
>     at javax.activation.DataHandler.getContent(Unknown Source)*
> 
> Please help me to resolve this issue.Any help would be much appreciated.
> 
> Thank you,
> Naresh.

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

Re: How to send attachment in response to a web service call

Posted by pkannan <pk...@gmail.com>.
Hi Narel, 

Did the upgrade fix the issue?  Were you trying to process the attachment in
.net client? 

My scenario: We are using 2.2 version of CXF. Have not used attachment
before. For the first time going to try sending attachments.  Any good
example would be helpful. 

Also looking for any tips to process the attachment in the SOAP response on
the client side. Our client is running .net framework. 

Appreciate any help. 




--
View this message in context: http://cxf.547215.n5.nabble.com/How-to-send-attachment-in-response-to-a-web-service-call-tp552017p5734296.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: How to send attachment in response to a web service call

Posted by Daniel Kulp <dk...@apache.org>.
My suggestion would be to update to CXF 2.2.9.   There were a lot of fixes 
that were put around various streaming attachment handling that may have 
likely fixed this already. 

I don't know if the 2.1.10 release (last on 2.1.x) would have all the 
attachment fixes or not.

Dan




On Thursday 10 June 2010 5:53:58 am Naresh Tallapelli wrote:
> HI All,
> 
>  I am using CXF-2.1.2 version. I have a requirement to send an attachment
> from web services server to the client as part of one  web service call
> response. I have created the response element as following in wsdl file,
> *
> <xsd:element name="fileStreamResponse" type="xsd:base64Binary"
> 
> xmime:expectedContentTypes="application/octet-stream" maxOccurs="1"
>                             minOccurs="1">*
> 
> When web service operation is called i am creating "FileDataHandler" for
> file and returning the handler as part of response. Server is able to send
> the attachment to the client. I can see the following log message on web
> services server side.
> 
> *<soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns5:test
> MtomResponseResponse><fileStreamResponse><xop:Include
> xmlns:xop="http://www.w3.org/2004/08/xop/include"
> href="cid:e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%2Fcxf.apache.org
> %2F"/></fileStreamResponse></ns5:testMtomResponseResponse></soap:Body></soa
> p:Envelope> ------=_Part_0_8371737.1276162616240
> Content-Type: text/plain
> Content-Transfer-Encoding: binary
> Content-ID: <e47836d1-3362-48ce-bbac-f1bd033ea2ef@http%3A%2F%
> 2Fcxf.apache.org%2F>
> 
> This is the response created intially on the server.*
> 
> But the client is not able to receive the attachment. In
> "AttachmentInInterceptor" if the message type is multipart, then we cxf
> code is loading the attachments lazily. That's the reason why the client
> is not able to get the response. Web services client is throwing the
> following exception,
> 
> *    java.io.EOFException: Unexpected end of ZLIB input stream
>     at
> org.apache.cxf.attachment.AttachmentDeserializer.readNext(AttachmentDeseria
> lizer.java:187) at
> org.apache.cxf.attachment.LazyAttachmentCollection$1.hasNext(LazyAttachment
> Collection.java:73) at
> org.apache.cxf.attachment.LazyDataSource.load(LazyDataSource.java:49) at
> org.apache.cxf.attachment.LazyDataSource.getContentType(LazyDataSource.java
> :59) at javax.activation.DataHandler.getContentType(Unknown Source) at
> javax.activation.DataHandler.getBaseType(Unknown Source)
>     at javax.activation.DataHandler.getDataContentHandler(Unknown Source)
>     at javax.activation.DataHandler.getContent(Unknown Source)*
> 
> Please help me to resolve this issue.Any help would be much appreciated.
> 
> Thank you,
> Naresh.

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