cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Naresh Tallapelli <naresh.tallape...@gmail.com>
Subject How to send attachment in response to a web service call
Date Thu, 10 Jun 2010 09:53:58 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message